我必须在一个频道中接收 UDP 并通过管道连接到 2 个订阅频道。为此,我有 2 个具有相同输入通道的 Serviceactivator 函数。
@Autowired
private PublishSubscribeChannel channel;
@Bean
public UnicastReceivingChannelAdapter udpIn() {
final UnicastReceivingChannelAdapter adapter = new
UnicastReceivingChannelAdapter(<port>);
adapter.setPoolSize(6);
adapter.setOutputChannel(channel); //Is it required?
adapter.setOutputChannelName("udpInboundChannel");
adapter.stop();
return adapter;
}
@ServiceActivator(inputChannel = "udpInboundChannel")
public void handleMessage(Message<?> message) throws MessagingException {
----
}
@ServiceActivator(inputChannel = "udpInboundChannel")
public void handleMessageDifferently(Message<?> message) throws MessagingException {
---
}
我的问题,我需要adapter.setOutputChannel(channel)
像这样设置频道吗?或者UnicastReceivingChannelAdapter
根据需要默认提供一个发布-订阅频道?
在您的配置中udpInboundChannel
是 DirectChannel。如果您希望它成为 PubSub 频道,只需声明一个新 bean
@Bean
public MessageChannel udpInboundChannel() {
return new PublishSubscribeChannel();
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句