Spring integration 网关方法中连接到同一请求通道的多个集成流
鉴于我有一个使用Spring集成的应用程序,我定义了网关:Spring integration 网关方法中连接到同一请求通道的多个集成流,spring-integration,Spring Integration,鉴于我有一个使用Spring集成的应用程序,我定义了网关: @Component @MessagingGateway public interface SmsGateway { @Gateway(requestChannel = CHANNEL_SEND_SMS) void sendSms(SendSmsRequest request); } public interface IntegrationChannels { String CHANNEL_SEND_SMS
@Component
@MessagingGateway
public interface SmsGateway {
@Gateway(requestChannel = CHANNEL_SEND_SMS)
void sendSms(SendSmsRequest request);
}
public interface IntegrationChannels {
String CHANNEL_SEND_SMS = "channelSendSms";
}
我还将IntegrationFlow
附加到CHANNEL\u SEND\u SMS
频道:
@Bean
public IntegrationFlow sendSmsFlow() {
return IntegrationFlows.from(CHANNEL_SEND_SMS)
.transform(...)
.handle(...)
.get();
}
每当我从业务代码调用sendsmsm
gateway方法时,sendSmsFlow
将按预期执行
当我想将另一个IntegrationFlow
附加到同一CHANNEL\u SEND\u SMS
频道时,例如
@Bean
public IntegrationFlow differentFlow() {
return IntegrationFlows.from(CHANNEL_SEND_SMS)
.transform(...)
.handle(...)
.get();
}
然后此differentFlow
不会执行
为什么会这样
是否有任何解决方案使其适用于两个流?默认通道类型为
DirectChannel
,默认情况下,消息以循环方式分发到多个订阅通道
如果希望每个流都能获得每条消息,请将CHANNEL\u SEND\u SMS
声明为publishsubscribebechannel
这仅适用于void
网关方法;如果有返回类型,您将得到第一个(如果有异步下游处理,则为随机),其他返回类型将被丢弃