Reputation: 86905
I'm using spring-integration
to connect a client to a server socket
using the following components:
DirectChannel
TcpConnectionFactoryFactoryBean
TcpOutboundGateway
@MessagingGateway
Problem: the TcpConnectionFactoryFactoryBean
is tied to a specific socket port. I'd like to connect the client to multiple server sockets.
How could I achieve this? Is that possible at all?
Upvotes: 3
Views: 1596
Reputation: 174759
Correct. You need a separate connection factory for each server/port.
There's not currently any mechanism in Spring Integration to dynamically select a TCP host/port for each message.
Such a mechanism would probably need to cache connections to avoid having to open a new socket for each request. Feel free to open a new feature JIRA issue and we'll consider it for a future release.
Upvotes: 1
Reputation: 224
A TCP connection is bound to following parameters:
I think it's not intended to offer the possibilty to create one to many connections via one socket since this would be against the TCP definition.
So the solution would be to create multiple sockets, each holding one connection to a different server.
Upvotes: 3