Thanks.
I was able to implement the connection pool using CachingClientConnectionFactory.
This is the configurations that I used.
Code:
<int-ip:tcp-connection-factory id="tcpConnectionFactory"
deserializer="deserializer" type="client" host="${socket.host}"
port="${socket.port}" so-keep-alive="true"/>
<int-ip:tcp-outbound-gateway id="outboundGateway"
request-channel="sendStringMessageChannel" reply-channel="recieveStringMessageChannel"
connection-factory="tcpConnectionPool" request-timeout="10000"
reply-timeout="10000" />
<bean id="tcpConnectionPool"
class="org.springframework.integration.ip.tcp.connection.CachingClientConnectionFactory">
<constructor-arg ref="tcpConnectionFactory" />
<constructor-arg type="int"
value="50" />
</bean>
<bean id="deserializer"
class="com.infrastructure.connection.SocketInputStreamDeserializer" />
But I am experiencing an issue when using the app after a long idle time.
Code:
Caused by: java.net.SocketException: Broken pipe
at java.net.SocketOutputStream.socketWrite0(Native Method)
at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:109)
at java.net.SocketOutputStream.write(SocketOutputStream.java:141)
at org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer.serialize(ByteArrayCrLfSerializer.java:74)
at org.springframework.integration.ip.tcp.serializer.ByteArrayCrLfSerializer.serialize(ByteArrayCrLfSerializer.java:31)
at org.springframework.integration.ip.tcp.connection.TcpNetConnection.send(TcpNetConnection.java:70)
at org.springframework.integration.ip.tcp.connection.AbstractTcpConnectionInterceptor.send(AbstractTcpConnectionInterceptor.java:122)
at org.springframework.integration.ip.tcp.TcpOutboundGateway.handleRequestMessage(TcpOutboundGateway.java:121)
... 92 more
Thanks in advance for any guidance related to this.