3

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?

2 Answers 2

3

A TCP connection is bound to following parameters:

  • Source address
  • Source port
  • Remote address
  • Remote port

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.

Wiki-Article for TCP

So the solution would be to create multiple sockets, each holding one connection to a different server.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.