Service Activator Handlers not running serially

限于喜欢 提交于 2019-12-13 03:43:05

问题


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();
}

回答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.



来源:https://stackoverflow.com/questions/47560693/service-activator-handlers-not-running-serially

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!