Service Activator Handler未按顺序运行 [英] Service Activator Handlers not running serially
问题描述
我无法让服务激活处理程序以串行方式运行,它们似乎不会一个接一个地运行。在下面的代码中,fileWriterMessageHandler方法在fileUpload方法之前调用。 fileUpload需要返回的标准返回值是什么?
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();
}
推荐答案
正如我在其他地方所说的那样地方,你应该回到书籍和参考手册。
As I said you in other place, you should come back to books and Reference Manual.
这里我们应该记住,在那些 .handle()$之间c $ c>有一个隐含的
MessageChannel
,第一个 .handle()
将执行结果发送给下一个。
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.
我真的怀疑他们可能会像你所描述的那样以错误的方式被召唤。但是,您可能会在日志中看到一些内容,因为所有内容都是通过 taskExecutor
以异步模式执行的。
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
.
我不知怎的相信 fileWriterMessageHandler()
是一个标准的 FileWritingMessageHandler
。这个期望 java.io.File
作为请求消息的有效载荷
。所以,如果你想在自定义服务方法之后调用它,你应该确保最后一个返回 File
对象而不是 boolean
。
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
.
这篇关于Service Activator Handler未按顺序运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!