1
votes

I am trying to start file inbound channel adapter via control bus, but I am getting exceptions while ExpressionCommandMessageProcessor is trying to parse my command.

Here is my inbound channel adapter configuration:

@Bean(name = "inboundChannelAdapter")
public IntegrationFlow inputFilesReadingFlow()
{
         return IntegrationFlows
                  .from(s -> s.file(new File(inputDirectory))
                              .filter(new AcceptAllFileListFilter<File>()),
                        e -> e.poller(Pollers.fixedDelay(FILE_POLLER_RATE))
                              .autoStartup(false)
                       )
                  .handle(messageProcessingService)
                  .channel(fileOutputChannel)
                  .get();
}

@Bean
public IntegrationFlow controlBusFlow()
{
    return IntegrationFlows.from("controlBusChannel").controlBus().get();
}

In my integration test I have autowired control bus bean:

@Autowired
private MessageChannel controlBusChannel;

@Test
public void testInboundChannelAdapter() 
{
    controlBusChannel.send(new GenericMessage<String>("@'inboundChannelAdapter.<property_name_placeholder>'.start()")); // ????

    // .....
}

So I'd like to ask how I can access 'adapter' bean(or whatever bean is responsible for the start/stop action) to initiate polling process.

Thank you.

1

1 Answers

1
votes

Along with the .autoStartup(false) you can find simple .id() hook.

Having that you will be able to start exactly desired SourcePollingChannelAdapter via ControlBus:

 controlBusChannel.send(new GenericMessage<>("@myFilePollingAdapter.start()")); 

Your confuse that IntegrationFlow represents a container for its bunch of beans and doesn't allow to get access to them, because they are registered as top-level beans anyway.

Although starting with version 1.2 StandardIntegrationFlow is SmartLifecycle already, so, you really can start/stop all those related beans at once. Including the first File Poller one.