0

I'm writing an IntegrationFlow using TcpInboundGateway. When the client connects and builds a connection to the server (inbound gateway), is there a way to send 'server initiated message' to that connection? I already know how to send 'reply' for incoming messages.

I have read that inbound gateway can configured with unsolicited message channel but cannot find relevant setter method in TcpInboundGateway class.

Starting with version 5.4, the inbound can be configured with an unsolicitedMessageChannel. Unsolicited inbound messages will be sent to this channel, as well as late replies (where the client timed out). To support this on the server side, you can now register multiple TcpSender s with the connection factory. Gateways and Channel Adapters automatically register themselves. When sending unsolicited messages from the server, you must add the appropriate IpHeaders.CONNECTION_ID to the messages sent.

To do this, do I need to make a use of TcpOutboundGateway together?

Jay Han
  • 5
  • 3
  • We need to understand your requirements better. For now the question: did you look already into TCP channel adapters, not gateways? So, the `TcpReceivingChannelAdapter` would connect on the client side and server via `TcpSendingMessageHandler` would send `server initiated message`. – Artem Bilan Jul 20 '23 at 16:05
  • Ok. So I tried TcpSendingMessageHandler which uses the same connection factory TcpInboundGateway uses. I succeeded to send 'server initiated message'. It seems also possible to make it work with `TcpReceivingChannelAdapter` and `TcpSendingMessageHandler` together with the same configuration. Thanks! – Jay Han Jul 21 '23 at 05:30

1 Answers1

0

For server initiated messaging it is recommended to use a combination of TcpReceivingChannelAdapter and TcpSendingMessageHandler on the client side. See some information in the docs: https://docs.spring.io/spring-integration/docs/current/reference/html/ip.html#ip-collaborating-adapters

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118