I am trying to implement/delegate my own TCP connection pool using the class TcpNetClientConnectionFactory for client tcp connection. Below is my bean definition and I've injected it in my outbound adapter. I am also using ThreadLocal to get the dynamic host that comes with the message so I'll be able to communicate it with the factory. I would like to have the connection factory (subclass of TcpNetClientConnectionFactory) to create/build a new connection again depending on the host provided in the message.
Though, I have no idea what is the best practice or approach for this scenario. If anyone could help, it would be very much appreciated.
<bean id="client2" class="com.xxx.yyy.connection.MyTcpNetClientConnectionFactory">
<constructor-arg value="localhost" />
<constructor-arg value="1234" />
<constructor-arg value="false" />
<constructor-arg value="10000" />
<constructor-arg value="false" />
<property name="serializer" ref="fastestWireFormatSerializer"></property>
<property name="deserializer" ref="fastestWireFormatSerializer"></property>
</bean>
<int-ip:tcp-outbound-channel-adapter
id="outAdapter"
channel="outChannel"
connection-factory="client2"
/>
This is the constructor for TcpNetClientConnectionFactory:
public MyTcpNetClientConnectionFactory(String host, int port,
boolean singleUse, int soTimeout, boolean soKeepAlive) {....}