gpt4 book ai didi

java - 没有输出 channel 的 Spring Integration 服务激活器

转载 作者:行者123 更新时间:2023-11-29 08:32:23 26 4
gpt4 key购买 nike

在我的代码中,我有一个入站适配器 channel 和一个服务激活器,我不想将服务激活器与出站 channel 连接,

我正在使用的代码

<file:inbound-channel-adapter id="filesIn"
directory="E:/usmandata/logs/input" filter="onlyLogFiles"
auto-startup="true">
<int:poller id="poller" fixed-delay="5000" />
</file:inbound-channel-adapter>

<int:service-activator input-channel="filesIn" ref="handler" />

最佳答案

如文档中所述,只需将其设为 void 返回类型或将其设置为 nullChannel

If the method returns a result and no "output-channel" is defined, the framework will then check the request Message’s replyChannel header value. If that value is available, it will then check its type. If it is a MessageChannel, the reply message will be sent to that channel. If it is a String, then the endpoint will attempt to resolve the channel name to a channel instance. If the channel cannot be resolved, then a DestinationResolutionException will be thrown. It it can be resolved, the Message will be sent there. If the request Message doesn’t have replyChannel header and and the reply object is a Message, its replyChannel header is consulted for a target destination. This is the technique used for Request Reply messaging in Spring Integration, and it is also an example of the Return Address pattern.

If your method returns a result, and you want to discard it and end the flow, you should configure the output-channel to send to a NullChannel. For convenience, the framework registers one with the name nullChannel. See Section 4.1.6, “Special Channels” for more information.

The Service Activator is one of those components that is not required to produce a reply message. If your method returns null or has a void return type, the Service Activator exits after the method invocation, without any signals. This behavior can be controlled by the AbstractReplyProducingMessageHandler.requiresReply option, also exposed as requires-reply when configuring with the XML namespace. If the flag is set to true and the method returns null, a ReplyRequiredException is thrown.

关于java - 没有输出 channel 的 Spring Integration 服务激活器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46804624/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com