I have a game server that uses websocket for real time multiplayers. It is a Spring 4 application and I use RabbitMQ as my broker. This is my configuration:
<websocket:message-broker application-destination-prefix="/app">
<websocket:stomp-endpoint path="/portfolio">
<websocket:sockjs/>
</websocket:stomp-endpoint>
<websocket:simple-broker prefix="/queue, /topic"/>
</websocket:message-broker>
From a very small test with 4 clients I saw 4 connections open on Rabbit.
Does each client that connects to my server using websocket eventually open a new connection to the broker (RabbitMQ)? Can this be configured?
Yes, each websocket client gets its own TCP connection to the broker. The documentation has a section for connections to the broker (emphasis mine):
A STOMP broker relay maintains a single "system" TCP connection to the broker. This connection is used for messages originating from the server-side application only, not for receiving messages. [...]
The STOMP broker relay also creates a separate TCP connection for every connected WebSocket client. [ ... ]
If this can be configured or not I don't know, I'm not all that familiar with this part of Spring, but I assume it should be; Spring is open to extension. My suggestion is to post an issue on the spring-websocket-portfolio project and ask for specifics.
EDIT : OP opened the following issue on the spring-websocket-portfolio project.
Related
I've encounter a problem where our WebSocket connections to ActiveMQ 5.13.3 are terminated abruptly. I thought, I might use WireShark to inspect the TCP layer for clues why the connection may be corrupted, but I'm not sure the ActiveMQ uses TCP protocol as its transport layer protocol for sending the messages.
All the kinds of clients and protocols which ActiveMQ supports use TCP as their transport layer. WebSockets specifically use TCP.
ActiveMQ Broker supports many transport layer protocols, including TCP.
References:
If you are using ActiveMQ Classic:
https://activemq.apache.org/components/classic/
If you are using ActiveMQ Artemis:
https://activemq.apache.org/components/artemis/
I was following the https://docs.spring.io/spring-boot/docs/2.0.0.M3/reference/html/boot-features-messaging.html#boot-features-artemis guide.
With Core protocol with JMS, app is able to send message to Artemis broker.
spring.artemis.mode=native
spring.artemis.host=<broker host>
spring.artemis.port=61616
spring.artemis.user=admin
spring.artemis.password=<password>
When I switched to AMQP protocol with 5672 port, I am getting below error.
spring.artemis.mode=native
spring.artemis.host=<broker host>
spring.artemis.port=5672
spring.artemis.user=admin
spring.artemis.password=<password>
Caused by: org.apache.activemq.artemis.api.core.ActiveMQConnectionTimedOutException: AMQ219013: Timed out waiting to receive cluster topology. Group:null
at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:712) ~[artemis-core-client-2.12.0.jar:2.12.0]
at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:884) ~[artemis-jms-client-2.12.0.jar:2.12.0]
... 68 common frames omitted
what changes I have to make along to enable transition over AMQP protocol in my spring boot app? Thanks.
In order to use the AMQP protocol you'd need to somehow force Spring to use the Qpid JMS client implementation rather than ActiveMQ Artemis' core JMS client implementation, but I don't believe that is possible.
I have the following design:
Machine1
WebsocketApp
ActiveMQ broker
Machine2
WebsocketApp
ActiveMQ broker
Machine3
WebsocketApp
ActiveMQ broker
Machine4
WebsocketApp
ActiveMQ broker
The clients will use STOMP over WebSockets through an F5 load-balancer to connect to the ActiveMQ brokers. They can land on any machines based on the load factor.
For fail over scenarios how do we share the web socket sessions between ActiveMQ. Otherwise if the broker goes down all the sessions that it is holding will go down.
STOMP is a very simple protocol. It has no support for fail-over.
If the broker to which a STOMP client is connected goes down in your environment then that client's connection will go down and all the messages on that broker will be unavailable until the broker comes back up. The client will need to reconnect to another broker via the F5 URL.
STOMP connections are not like HTTP. They are stateful. Client "session" data is not shared among brokers. If a client's broker goes down then it cannot simply carry on as if nothing happened like is often possible for HTTP use-cases.
I'm behind a corporate HTTP proxy and want to send and receive messages to/from a ActiveMQ Artemis broker in the cloud.
On the broker Netty HTTP is activated and I'm able to send and receive messages using the Netty based ActiveMQ Artemis client on a computer without HTTP proxy.
I know that Netty HTTP client can be configured to use a HttpProxyHandler but I didn't find a way to configure this with the ActiveMQ Artemis client.
Any help is highly appreciated.
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