How do I send a response for TCP requests (spring integration)?
I need something like this, for example in Can't send reply to UDP message but for TCP. Thus, the client message and the TCP server can send back a response like OK. For TCP, socket-expression = "@ inbound.socket" and destination-expression = "headers ['ip_packetAddress']" cannot be used.
This is what my config looks like now:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-ip="http://www.springframework.org/schema/integration/ip"
xmlns:int-event="http://www.springframework.org/schema/integration/ip"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/ip http://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd">
<int:channel id="tcpSend"/>
<int-ip:tcp-connection-factory id="client" type="client"/>
<int-ip:tcp-connection-factory id="server" type="server" host="localhost" port="1234"/>
<int-ip:tcp-outbound-channel-adapter id="tcpOutbound" channel="tcpSend"
connection-factory="client"/>
<int-ip:tcp-inbound-channel-adapter id="tcpInbound" channel="tcpReceive"
connection-factory="server"/>
<int:service-activator id="tcpHandler" input-channel="tcpReceive" output-channel="tcpSend"
ref="listener"/>
</beans>
+3
source to share
1 answer
In the case of TCP, this is much easier because you can use the Inbound Gateway .
A sample for this question is in the official repository: https://github.com/spring-projects/spring-integration-samples/tree/master/basic/tcp-client-server
+3
source to share