I have a Spring Integration application that is using a Inbound/Outbound Adapter combination for sending and receiving TCP messages. I am trying to correlate the message that is sent with the response that is received for that request but am running into some issues.
My current configuration looks like this...
@Bean
public AbstractServerConnectionFactory serverConnectionFactory() {
return new TcpNetServerConnectionFactory(15000);
}
@Bean
public TcpReceivingChannelAdapter inboundAdapter() {
TcpReceivingChannelAdapter inboundAdapter = new TcpReceivingChannelAdapter();
inboundAdapter.setConnectionFactory(serverConnectionFactory());
inboundAdapter.setOutputChannel(receiveResponse());
return inboundAdapter;
}
@Bean
@ServiceActivator(inputChannel="sendRequest")
public TcpSendingMessageHandler outboundAdapter() {
TcpSendingMessageHandler outboundAdapter = new TcpSendingMessageHandler();
outboundAdapter.setConnectionFactory(serverConnectionFactory());
return outboundAdapter;
}
@Bean
public MessageChannel receiveResponse() {
return new DirectChannel();
}
@MessagingGateway(defaultRequestChannel="sendRequest", defaultReplyChannel="receiveResponse")
public interface RequestSender {
public String sendRequest(@Payload String payload, @Header(IpHeaders.CONNECTION_ID) String connectionId);
}
Everything configures as expected on boot, when the RequestSender.sendRequest()
method is called the message is sent, a response is sent back (I have another application that is responding) but I run into the follow error once the response hits my inboundAdapter
. The error is...
org.springframework.messaging.MessageDeliveryException: Dispatcher has no subscribers for channel 'application.receiveResponse'.
Based on what I have read about the MessagingGateway
, the replyChannel
is the channel for which the gateway will listen on for a reply. So I would think that whatever the inbound adapter receives, that is what would ultimately be returned from the RequestSender.sendRequest()
method. However, in my case it appears the MessagingGateway
is failing to subscribe to the receiveResponse
channel.
Is there a way to implement a MessagingGateway
in this fashion? If so, what seems to be preventing my current configuration from acting in the way that I hope for?