Configure STOMP over websocket in Wildfly 9 - websocket

I need to configure STOMP over websocket inside wildfly 9. What I did so far,
After following help on the internet, I added connectors/acceptores in standalone-full.xml for configuring STOMP over websocket. The configuration looks as follow:
And adde socket-bindings for the same (port 61614).
With this configuration, wildfly 9 starts. But I am not able to connect to STOMP over websocket. Trying to connect using java websocket client over ws://localhost:61614/stomp. But not able to connect using the same. I also tried using the javascript STOMP client library to connect. But result is same and not able to connect using same. (As described here, http://jmesnil.net/stomp-websocket/doc/)
Now after this, I tried adding STOMP_WS protocol on acceptor configuration:
But when I start Wildfly 9 with this, I results in error saying "Error instantiating remoting acceptor org.hornetq.core.remoting.impl.netty.Netty.NettyAcceptorFactory: HornetQException[errorType=GENERIC_EXCEPTION message=HQ119085: Classpath lacks a protocol-manager for protocol STOMP_WS]"
One other thing is when I start wildflly 9, I see following lines in logs,
10:37:33,866 INFO [org.hornetq.core.server] (ServerService Thread Pool -- 64) HQ221043: Adding protocol support CORE
10:37:33,878 INFO [org.hornetq.core.server] (ServerService Thread Pool -- 64) HQ221043: Adding protocol support AMQP
10:37:33,881 INFO [org.hornetq.core.server] (ServerService Thread Pool -- 64) HQ221043: Adding protocol support STOMP
But I don't see same for STOMP_WS protocol.
So my question is,
1. How to configure STOMP_WS in wildfly 9?
2. If I only configure STOMP with netty connector/acceptor, does that mean it is STOMP over websocket?
I have tried all this in Wildfly 8,9 and 10 and same things is observed in each versions.
Any help is very much appreciated!!

This issue is fixed after changing Netty jar in Wildfly 9. Earlier it was netty-all-4.0.26.Final.jar. I replaced it with netty-all-4.0.13.Final.jar. Now I am able to connect to STOMP over websocket with following configuration:
<netty-acceptor name="netty-acceptor" socket-binding="netty">
<param key="protocols" value="STOMP"/>
</netty-acceptor>
NOTE: I didn't use STOMP_WS protocol.

Related

Amazon MQ transforming AMQP message to JMS

I have a Python and Java Spring application communicating 2 ways. The stack is mostly built on Java/Spring so ActiveMQ and JMS were the logical choices. However, we added a Python application that needed to interact with the rest of the services so I used qpid proton (AMQP library) and added the following configuration inside the ActiveMQ configuration to get it working:
<transportConnectors>
<transportConnector name="openwire" uri="ssl://0.0.0.0:61617?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>
<transportConnector name="amqps" uri="amqp+ssl://0.0.0.0:5671?maximumConnections=1000&wireFormat.maxFrameSize=104857600&transport.transformer=jms"/>
</transportConnectors>
which worked flawlessly on ActiveMQ and allowed to send/receive JMS TextMessage with an AMQP client.
Unfortunately, Amazon MQ refused this configuration and returned the following error:
The value 'amqp+ssl' of attribute 'name' on element 'transportConnector' is not valid with respect to its type, 'protocol'. and cvc-enumeration-valid: Value 'amqps' is not facet-valid with respect to enumeration '[openwire]'
AWS markets Amazon MQ as a managed ActiveMQ service but they seem to be lacking in functionalities since the mapping from AMQP to JMS has been available since version 5.8: https://activemq.apache.org/amqp and the Amazon MQ broker that I'm using is at version 5.15.12
I have tried adding the amp;transport.transformer=jms and transport.transformer=jms headers to the query string of the broker's URL, as well as using STOMP as the protocol (since it is a plain-text protocol) in the Python app instead of AMQP but none of these worked.
So, do you know any potential missing configurations or other ways I could send an AMQP message in my Python app and receive a JMS TextMessage in the Java app?
By default in the open source ActiveMQ 5.x code the AMQP transport already defaults to the JMS transformation so unless the Amazon version has altered that you shouldn't need to even set that explicitly if you want JMS transforms of the inbound AMQP messages. If they've altered that then you'd need to contact them to determine how to change that configuration.

java webscoket client for Rabbit mq Stomp

I am looking for creating a websocket client for using rabbit mq stomp over websocker using java.
I using jetty client and i am getting org.eclipse.jetty.websocket.api.UpgradeException: Didn't switch protocols
Looks like the issue is with the Rabbit MQ version. After I've upgraded from Ubuntu default one to the newest Rabbit MQ version from https://www.rabbitmq.com/install-debian.html it worked for me.
Look at this example: stomp-websockets-java-client
Please read first:
http://jmesnil.net/stomp-websocket/doc/
http://www.rabbitmq.com/blog/2012/05/14/introducing-rabbitmq-web-stomp/
not perfect, it's far from the worst way do messaging in the browser: exposing STOMP through Websockets.

How does Spring mange websocket connections to RabbitMQ?

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.

How to connect Glassfish 3 to an external ActiveMQ 5 broker

I need to be able to consume and produce messages to and from our activemq cluster from applications deployed on glassfish 3.
How should I configure glassfish in order to achieve this?
I've found some info on how to run an embedded activemq broker in glassfish, and although this is not what I was looking for, I was able to figure out how to change the config to connect to an external broker.
I've written an article about how to do this: http://geertschuring.wordpress.com/2012/04/20/how-to-connect-glassfish-3-to-activemq-5

Sending a JMS message to a remote queue on JBoss AS 5 and AS 7

I have two servers
JBoss as 5.1 with an application sending JMS messages
JBoss AS 7 server with the queue implemented and an MDB consuming messages
I would like to send a message from server one to server two. I would like the message to be consumed on server two.
I think JBoss AS 7 uses HornetQ.
Any hints on how to send a message to a remote queue? I'm more interested on how to send messages because it is on the remote server, and I think the consuming part should be straight forward.
You are correct that JBoss AS 7 uses HornetQ for messaging as the JMS provider. A great resource is the JBoss community documentation for HornetQ. There is also an excellent post on the JBoss community forums about setting up HornetQ across two instances of AS 7.
You will need to define your connectors and acceptors that make up the transports, which in your case will include netty as your client and server are running in different JVMs (otherwise you could use invm). Creating your connection factories will differ on each JBoss AS instance (for example, there is no Management CLI on JBoss AS 5), but the above link will give you a good reference, and you can ask targeted questions in there.

Resources