Wins
Wins

Reputation: 3450

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

Upvotes: 7

Views: 1623

Answers (1)

Artem Bilan
Artem Bilan

Reputation: 121542

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.

Upvotes: 3

Related Questions