New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extensible invocation of TcpClient in ReactorNettyTcpClient #25889
Comments
If you override Also could clarify how this would minimize traffic inside the cluster? |
You mean, a protected method in |
I do not see how what you are suggesting can solve the problem. I override that new method, and then what? I call the super and I just get the Mono, but I still won't have any control on deciding where to connect that specific session without writing some sort of pool of btw, I forgot to clarify the use case: Tomcat 1 ---- post msg to user2 ----> Stomp Broker 1 ----> Stomp Broker 2 ----> Tomcat 2 ----> user2 So we basically want to make sure that all our tomcat servers in the cluster, when delivering a message to "user2" get all connected to where user 2 is connected. As otherwise there will be some internal traffic and lag happening. So the picture looks more like this: Tomcat 1 ---- post msg to user2 ----> Stomp Broker 2 ----> Tomcat 2 ----> user2 You understand what I mean? |
It would be something like this by default: protected void connectHandler(StompHeaderAccessor accessor,
TcpConnectionHandler<byte[]> handler, @Nullable ReconnectStrategy strategy) {
getTcpClient().connect(handler);
} You would then override that and choose a differently customized client depending on the info in the STOMP headers. |
yes, that could kind of work, it is not super nice, since I will have to instantiate a ConnectionProvider, LoopResources and TcpClient for each of these tcpClient, but it will be assumable if you think this is an edge case. Hopefully another approach will arise in the future, with a more solid support for client side load balancing. |
I've added something along the lines of your pull request but with a |
yes, I have checked your commit. Looks great, no objection. Thanks so much for your time. |
We would like to achieve something as basic as sending all Stomp sessions from a specific user to one Stomp relay, while other users may go to other Stomp relays. This should minimize I believe the traffic inside the Artemis cluster.
I know I can use
TcpClient#remoteAddress(Supplier...)
but this is not enough for what we try to achieve. We need to know the context of the incoming connection to know to whichremoteAddr
send that to. I mean, we need to gather the session id / user principals of the incoming session, to decide to which relay it should send that Connect request to.I know I could extend
ReactorNettyTcpClient
and Overrideconnect(TcpConnectionHandler)
but then I need to reimplement myself the wholeReactorNettyHandler
(as this one is private).Ideally
ReactorNettyTcpClient
should internally allow some sort oftcpClient resolver
, or at least it should, I think, use a getter for theTcpClient
(so that I can override the getter myself).Is this possible at all with the current code base? What would be then the correct way to achieve this?
The text was updated successfully, but these errors were encountered: