Reputation: 933
I am working on a high-volume integration with using spring integration tcp and I only send a request and receive more than millions of data over one connection and the time between two receiving message is lower than 100 milliseconds.
Here is my context xml and I am using TCPOutboundGateway.
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-ip="http://www.springframework.org/schema/integration/ip"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/integration https://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/ip https://www.springframework.org/schema/integration/ip/spring-integration-ip.xsd">
<bean class="org.springframework.integration.samples.tcpclientserver.EchoService"
id="echoService"/>
<bean class="org.springframework.integration.samples.tcpclientserver.ByteArrayToStringConverter"
id="javaDeserializer"/>
<int-ip:tcp-connection-factory
apply-sequence="true" deserializer="javaDeserializer"
host="127.0.0.1"
id="TCPClientFactory1"
port="443"
single-use="false"
type="client"
/>
<int-ip:tcp-outbound-gateway
async="true" close-stream-after-send="false" connection-factory="TCPClientFactory1"
id="outGateway"
remote-timeout="10000"
reply-channel="serverBytes2StringChannel"
reply-timeout="10000"
request-channel="input"
request-timeout="10"
/>
<int:channel id="input"/>
<int:channel id="toSA"/>
<int:gateway default-request-channel="input"
id="gw"
service-interface="org.springframework.integration.samples.tcpclientserver.SimpleGateway"/>
<int:object-to-string-transformer auto-startup="true" id="serverBytes2String"
input-channel="serverBytes2StringChannel"
output-channel="toSA"/>
<int:service-activator
input-channel="toSA"
method="test"
ref="echoService"
/>
<int:transformer expression="payload.failedMessage.payload + ':' + payload.cause.message"
id="errorHandler"
input-channel="errorChannel"/>
</beans>
I took an example from github. My issue is; I can successfully handle and process first received message. But the rest is got below exception.
20:21:34.550 [pool-1-thread-1] ERROR org.springframework.integration.ip.tcp.TcpOutboundGateway - Cannot correlate response - no pending reply for 127.0.0.1:443:57385:e164052f-64e5-4d41-9d46-4a12bad12cd4
I read the source code of TcpOutboundGateway and also read caching client connection factory document but could not found a proper way to achieve solution.
Upvotes: 0
Views: 291
Reputation: 174494
The gateway is not designed for that scenarion it only supports 1 reply per request.
You can use a pair of outbound/inbound channel adapters, instead of the gateway, for scenarios like this.
The upcoming 5.4 release has an enhancement to the gateway to support this scenario.
Upvotes: 1