Results 1 to 4 of 4

Thread: TCP sock connect factory questions

  1. #1

    Default TCP sock connect factory questions

    Hi,

    I am implementing a software load balancer for a cluster of servers and each server is implemented with Spring integration using TCP gateway. The cluster nodes may be up and down at runtime and I have a mechanism to detect the active nodes at the runtime.

    But my problem is that the load balancer needs to connect to different servers, i.e., different hosts and port numbers. The TCP connection factory in Spring integration requires to specify the host and port when it is created. But for my case, the tcp hosts and port numbers are dynamic at runtime. If I don't want to write my TCP connection factory for different hosts and port numbers from scratch, does Spring integration provide a conveinent way to do that? Any special attention I need to pay for NIO TCP connections?

    Thanks in advance,

    John

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,142

    Default

    No, Spring Integration doesn't support dynamic configuration of any outbound adapters and gateways (not just TCP).

    You could possibly create them programmatically and put them behind a <service-activator />, or configure them all statically and use a router to select a specific instance.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    Dec 2010
    Posts
    2

    Default

    Gary

    I have the same situation but I do not understand what is the use of the service activator here?

    Could you please clarify that point.

    Thanks in advance and best regards

  4. #4
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,142

    Default

    All I was trying to say is that, in Spring Integration, an outbound adapter or gateway has a fixed destination. If you want to do something more dynamic, you would have to write your own code, probably in a java class, configured as a <service-activator/>.

    You can then do whatever you want with the messages arriving thereto, including rolling your own socket handling code. You may be able to leverage existing SI components to help (such as TCP connection factories), but it will require some understanding of how they work. You can explore the source code for that; probably a good place to start is the test cases.

    Another alternative would be to implement your own connection factory, and inject it into the adapters/gateways.

    HTH
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •