Thursday Jun 19, 2014

JMS over WebSocket

Any application server which conforms to the Java EE Full Profile needs to include a messaging provider which supports the JMS API. Open Message Queue (aka Open MQ), the world first JMS 2.0 compliant MOM (Message Oriented Middleware), is the JMS provider for GlassFish. As GlassFish, Open MQ is open source too. Currently, GlassFish 4.0 is using Open MQ 5.0. In GlassFish 4.0.1, we plan to move to Open MQ 5.0.1. The 5.0.1 release comes with a set of fixed issues (see here) but also introduces new features such as WebSocket and STOMP support. 

The JMS specification is a messaging API and as such, it doesn't define the protocol to use on the wire. It is up to the JMS implementer to decide how to handle this. Open MQ supports socket TCP connections, it also supports HTTP/S tunnelling to make JMS messages easily flows through firewalls (See Annex C of the Open Message Queue Administration Guide).

With Open MQ 5.0.1, it is now possible to use WebSocket as the communication protocol between a client and an Open MQ JMS broker. Under the hood, Open MQ uses Grizzly and Tyrus.

A Java client will continue to use the JMS API so this is transparent. The only thing you have to take care is to specify, in your connection factory, the WebSocket URL of the Open MQ JMS Broker (imqAddressList=mqws://<broker-host>:<broker-ws-port>/<ws-service-name>). 

In addition, Open MQ 5.0.1 introduces 2 additional types of WebSocket clients, i.e. 'non JMS' clients that can be used to exchange messages with applications that do use JMS : 

  • mqstomp : Any (WebSocket) client that support STOMP 1.2 protocol
  • mqjsonstomp : Any (WebSocket) client that can sends JSON formatted STOMP 1.2 protocol
Those new types of clients are particularly interesting as they open the space for new scenarios (e.g.. simple JavaScript clients). The only thing the client need to have, in order to exchange messages with JMS applications, is STOMP and WebSocket support.

To find out more about this, you can check the 'JMS and WebSocket for Lightweight and Efficient Messaging' session that was presented during last JavaOne. You can also download and try Open MQ 5.0.1 today.