Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is equivalent of <tcp-outbound-channel-adapter> in java config?

I have the spring integration XML config with following bean

<int-ip:tcp-outbound-channel-adapter id="outboundClient"
channel="input"
connection-factory="client"/>

I thought the equivalent in java config would be

@ServiceActivator(inputChannel = "input", requiresReply = "true")
public TcpSendingMessageHandler outboundClient() {
    TcpSendingMessageHandler tcpSendingMessageHandler = new TcpSendingMessageHandler();
    tcpSendingMessageHandler.setConnectionFactory(clientConnectionFactory());
    tcpSendingMessageHandler.setRetryInterval(10000);
    tcpSendingMessageHandler.setClientMode(true);
    return tcpSendingMessageHandler;
}

However, in the log, I see

TcpListener exiting - no listener and not single use

and I can't receive the reply from server.

Any help is appreciated

like image 393
Wins Avatar asked Mar 03 '15 08:03

Wins


1 Answers

The TcpSendingMessageHandler is for one-way usage - just for sending messages to the TCP socket.

So, your config looks good and seems for me it should work.

TcpListener exiting - no listener and not single use

Is just DEBUG message from the TcpNetConnection which indicates that your component is one-way.

Therefore it is normal that you can't receive a reply from the server. Because you only send message to there.

To have request/reply scenarios consider to use TcpOutboundGateway.

like image 142
Artem Bilan Avatar answered Sep 28 '22 12:09

Artem Bilan