我想知道在Spring Integration中是否可以在流程中包含一个外部通道。所以,我有一个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应该实现为一种轮询器,它检查是否已到达正确的消息。
谢谢你的帮助。