0
votes

I would like to be able to implement a TCP connection pool/factory that will be able to accept a dynamic host during runtime.

For example I have an outbound channel adapter that is referenced to a client connection factory. The host will need to change depending on the message in the outbound channel adapter.

I know that the host is static in this configuration. My question is, how to customize or extend the class for tcp-connection-factory to be able to connect to changing hosts. Or if there's other better way to fulfill the expected outcome, what would be that solution?

<int-ip:tcp-outbound-channel-adapter
    id="outAdapter" 
    channel="outChannel"
    connection-factory="client" />

<int-ip:tcp-connection-factory id="client"
    type="client"
    host="${dynamicHost}"
    port="1234"
    single-use="false"
    so-timeout="10000" />
1

1 Answers

0
votes

It's not currently possible/easy - we have an open new feature request in JIRA to provide that functionality.

The problem is that the connection factory does not currently have access to the message when the adapter calls its getConnection() method. So we need some API changes to properly support this feature.

In the meantime, you could write your own delegating connection factory but it would not be trivial and you would need to use a ThreadLocal or similar to communicate the message context to the factory so it can decide which connection is needed.