Background: I have a system where, ordinarily, each user connects to a server via a long-running TCP connection. Each user has their own private key for connecting to the server over this TCP connection. When a user sends a message to the server, the server broadcasts that message back out to some or all of the other users via their active TCP connections.
Problem: For some set of these users, we want them to be able to communicate to the server via multicast, so I'm building a multicast<->TCP proxy server for this (we don't control the code for the original server, so editing it to handle multicast traffic isn't possible). This proxy will communicate with the users via multicast, and communicate with the server via TCP connections. For each user sending messages to the proxy, the proxy should have a separate TCP connection to the server that uses the private key of that end user for connecting to the server. I'm trying to set up these communication flows in Spring Integration, but I'm struggling to figure out if this setup is even feasible in this framework or if I'd be better off writing something custom for this purpose.
Right now, the biggest part I'm struggling with is on the TCP side. Conceptually, on the user->server part, I have a multicast receiver adapter that branches out into two flows, one for creating new connections with the information received in the multicast message, and one for sending data along an already-created connection. Is there a way to be creating these TCP connections in one flow, and then persisting that connection information in some way for it to be used by the other flow? These established connections would also need to be used for receiving messages on the server->user side of things as well. I'm struggling to figure out what the right way to accomplish this is within the framework.
Please let me know if there's any additional information I could give that would be helpful in answering this question, I know it's a pretty odd situation I'm trying to resolve here.
ThreadAffinityClientConnectionFactorybut instead of binding a single connection to the thread you would change the bound connection based on which client the request came from.