0

I am unable to get the service activator handlers run serially, they don't seem to run one after the other. In the below code, the fileWriterMessageHandler method is called before the fileUpload method. What is the standard return value that the fileUpload needs to return?

@Bean
public IntegrationFlow 
inboundChannelFlow(@Value("${file.poller.delay}") long delay,
@Value("${file.poller.messages}") int maxMsgsPerPoll,
TaskExecutor taskExecutor, MessageSource<File> fileSource) 
{
return IntegrationFlows.from(fileSource,
        c -> c.poller(Pollers.fixedDelay(delay)
                .taskExecutor(taskExecutor)
                .maxMessagesPerPoll(maxMsgsPerPoll)))
        .handle("AWSFileManager", "fileUpload")
        .handle(fileWriterMessageHandler())
        .channel(ApplicationConfiguration.inboundChannel)
        .get();
}
Raven21
  • 35
  • 2
  • 9

1 Answers1

1

As I said you in other place, you should come back to books and Reference Manual.

Here we should keep in mind that in between those .handle() there is an implicit MessageChannel and the first .handle() sends the result of its execution to the next one.

I'm really doubt that they may be called in wrong way as you described. However you might see something in your logs because everything is performed in async mode via that taskExecutor.

I somehow believe that fileWriterMessageHandler() is a standard FileWritingMessageHandler. This one expects a java.io.File as a payload of the request message. So, if you would like to call this after your custom service method, you should ensure there that the last one returns a File object instead of boolean.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • Thank you so much Artem for quickly replying to all my questions and being so patient answering them perfectly. Are there good books that I can follow on Spring Integration, I found some blogs and this https://docs.spring.io/spring-integration/reference/ would this be enough or do I need to refer something else? – Raven21 Nov 29 '17 at 20:14
  • This one is a theory: http://www.enterpriseintegrationpatterns.com. And this comes as a description for Spring Integration: https://www.manning.com/books/spring-integration-in-action. Samples are here: https://github.com/spring-projects/spring-integration-samples – Artem Bilan Nov 29 '17 at 20:18
  • Hey Artem, I see that the links you have provided do not specify anything about dsl , would that still be fine if I just look through spring integration with examples not concerning dsl though Im currently working on spring integration dsl. – Raven21 Nov 29 '17 at 21:12
  • Well, DSL is just an addition to the existing `channel -> consumer -> handler` model. You should get used to that first of all and only after that jump into the DSL "hell". It is here any way: https://docs.spring.io/spring-integration/docs/5.0.0.RELEASE/reference/html/java-dsl.html – Artem Bilan Nov 29 '17 at 21:15