问题
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