[英]Spring Integration DSL - Wait for input from channel in the flow
我想知道在弹簧集成中是否有可能在流程中包含一个外部通道。 所以我有http入站网关流,在它被触发后,它应该通过udp端口与其他进程通信。 我最关心的是如何从此流程中的udp端口接收消息。
@Bean
public IntegrationFlow httpInboundGatewayFlow() {
return IntegrationFlows.from(Http.inboundGateway(httpInboundPath))
.transform(niUdpRequestTransformer())
/*sending a message to udp port*/
.publishSubscribeChannel(runnable -> runnable
.subscribe(flow -> flow
.handle(udpOutboundChannel())))
/*wait for input from udpResponse channel here (HOW TO?)*/
/*process udpInboundFlow message*/
.handle((payload, headers) -> successNetworkResponse())))
.transform(new ObjectToJsonTransformer())
.handle((payload, headers) -> payload)
.get();
}
@Bean
public IntegrationFlow udpInboundFlow() {
return IntegrationFlows.from(udpInboundChannel())
.transform(niUdpResponseTransformer())
.channel("udpResponse")
.get();
}
使用udpInboundFlow应该被实现为某种轮询器,它检查是否有正确的消息到达。
谢谢你的帮助。
你所说的是所谓的相关性 。 而且我不知何故相信您希望得到某种对UDP请求的回复。
所以,你需要的确是这样的:
.channel("udpResponse")
.aggregate(...)
您应该为请求消息找出一些correlationKey
,并确保来自UDP的回复具有相同的密钥。 聚合器应配置为.releaseStrategy(group -> group.size() == 2)
。
第一条消息将是请求1,第二条消息确实是外部udpResponse
的结果。
有关详细信息,请参见参考手册
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.