0

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.

8
  • It's not clear what problem you are having; it shouldn't be difficult based on your description; maybe add some code to show what you have tried? Commented Oct 13, 2020 at 14:53
  • Part of my problem is I'm not even sure how to get this started in code. My thoughts were that the TCP outbound handler would take a connection factory, and I thought maybe creating a custom connection factory would be the right way to have a different connection based on what end user device the traffic came from, but I wasn't sure how to be passing the attributes of the message into that connection factory for each of those message flows. Internal to the connection factory there would be some kind of cache of connections. Also unsure how to use that factory for inbound connections. Commented Oct 14, 2020 at 1:36
  • 1
    It sounds like a custom connection factory would be the best approach; it could be based on the ThreadAffinityClientConnectionFactory but instead of binding a single connection to the thread you would change the bound connection based on which client the request came from. Commented Oct 14, 2020 at 13:58
  • I took a look at that code, that definitely seems closer to what I need, but I still need to get the information about the client's connection information from the multicast messages into that custom ClientConnectionFactory for establishing these connections, and I don't see how to do that while. The proxy server needs to be able to store this connection information so the users no longer need to worry about connection overhead from their own devices beyond that initial registration. Commented Oct 14, 2020 at 15:33
  • Maybe the connection flow just stores that information at the end in some kind of cache/repository, and the data flow would use a connection factory that takes a reference to that cache/repository for creating connections? But I'd still need to read the user identifier from the data message to determine what connection info from the cache to use, because users are expected to drop on and off the network frequently, and sometimes different devices will use the same private key for authentication. Also, thanks for all your help so far with this. Commented Oct 14, 2020 at 15:33

0

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.