I am going through Spring 4 websocket + stomp + rabbitmq(RabbitMQ-Web-Stomp plugin) architecture and I have a question about clustering. As per my understanding here Spring MVC act as a gateway for STOMP requests. If we cluster the application instance with spring web socket configuration will it create any confusion? For an example will it open multiple listeners and how will in such a case this architecture behave?
In this scenario, you would need to use load balancing and a message broker. I used HAProxy to load balance 4 Spring MVC instances (websocket) running on 4 tomcat servers. Also configure rabbit mq as a broker. From client code connect to the single HAProxy url.
If you don't use the message broker, then the websocket client subscriptions will be maintained in the app/ web server's (tomcat) JVM and in case one instance goes down, all the subscriptions on that would be lost.
Related
We are developing an application using Spring Boot and Apache Camel that is reading a message from ActiveMQ Artemis, doing some transformation, and sending it to ActiveMQ Artemis. Our application is deployed as war file in on-premise JBoss EAP 7.2.0. Both the source and target applications are remote to our application and they are also deployed on JBoss EAP 7.2.0. The remote queues to which Camel is connecting are ActiveMQ Artemis which were created in JBoss and connecting using http-remoting protocol. These setup was working when there were only one node of each of the applications.
Now we are making the source and target applications 3 nodes each (i.e. they will be deployed in multiple JBoss servers). For accessing the front-end of the source and target applications we are configuring and accessing them through a load balancer.
Can we configure the load balancer to access the source and target brokers from the Camel layer? There will be 3 source and 3 target brokers. Or is clustering the brokers the only option in this case?
We are thinking of load balancing between the queues and not clustering. Suppose we have three queues q1, q2, and q3 with corresponding brokers b1, b2, and b3. I will configure the load balancer url in the Camel layer like http-remoting://<load-balancer-url>:<port> (much like we do while load balancing HTTP API requests). Any message coming in will hit the load balancer, and the load balancer will decide which queue to route the message to.
JMS connections are stateful. When a client creates a connection there is no indication of the queues to which it will send messages. The load-balancer will have to direct that client's connection to either b1, b2, or b3 and it will have no way to determine where it should go. A load-balancer working with messaging will almost certainly only be able to balance connections, not messages. It sounds like you want load-balancing at the message level instead. Perhaps you should look into something like Qpid Dispatch Router.
Messaging doesn't use HTTP so using an HTTP load balancer like you do with your HTTP API(s) won't work. It's easy for a load-balancer to inspect HTTP headers and route requests, especially since HTTP is stateless. However, messaging connections are stateful and the protocols are typically quite a bit more complex than HTTP. I don't know of any load-balancers that will work the way you are wanting for messaging.
You need your client not to use the topology, you can do this by using "setUseTopologyForLoadBalancing" on your AMQConnectionFactory. If you get the connection factory from EAP I think this is configurable on the connection factory since EAP 7.3.
We have a use case to create websocket server. Mobile clients will connect to this websocket server. However mobile clients doesn't support stomp.
We would like to create a Java websocket server. spring does support websockets but it's heavily coupled with STOMP. we like to use Spring message broker concept here but because of Stomp, we are struck now. Is there anyway to overcome this and enable Spring websocket without STOMP but with Spring message broker concept?
We have written simple message sending mechanism to client (logged in user based) from server by using spring boot + websocket.
Currently its running in a single server, which is working fine.
But our production servers running under load balancing environment.
How could we achieve where the messages are pushed from server nodes send to appropriate users.
Please advice the possibilities, I have read some articles about RabbitMQ with socketjs , but not clear will it work for load balancing.
Thanks
If you have multiple instances of your websocket server, then every instance needs to know the sessions that exists on other instances.
Therefore you need to use a broker relay (not the in-memory broker given by spring) and set the UserRegistryBroadcast property.
You can find some info related to this at the end of this talk https://www.youtube.com/watch?v=nxakp15CACY
I am working to build an application (Server side) which should pick message from tibco jms queue and then post that to a url at which the Client (written in angular js) will listen, and also from client when some actions are taken then the server should listen to those actions and perform respective actions.
I can read from tibco jms queue and can place it to a spring integration channel.
My question here is that, can this be build using spring integration websocket adaptors (inbound & outbound) ? If yes then can someone help me with some references for sending to the client and receiving from the client adaptor configurations ?
All the info about Spring Integration Websocket module is in the Reference Manual.
You also can take a look to a couple samples:
Simple plain Websockets
Chat based on STOMP protocol
I need to implement a real-time scenario via web sockets and ZeroMQ queue.
SockJS with Stomp in the client side
Spring MVC / Integration with #EnableWebSocketMessageBroker
Remote messaging queue with ZeroMQ
At this moement, I could connect client and Spring via web sockets but I need to add the magic of remote queues.
ZeroMQ is available from 2 remote URLs (one for publishing and another one for subscribing).
My question is: How can I implement ZeroMQ in order to stay listening subscribed URL or the publishing URL?
Additionally, this type of functionality is conceptually similar to Spring Integration Outbound Gateways which stay listening for the response. Is it possible to implement ZeroMQ via Spring integration?
Thank you
We have an open JIRA issue to add ZeroMQ support to Spring Integration.
But nothing is implemented yet; contributions are welcome!.