How to use the OpenMQ Broker separately to Payara Server
Originally published on 30 Mar 2016
Last updated on 05 Apr 2016
Payara Server comes bundled with OpenMQ, which implements the Java Message Service (JMS) standard.
For simple messaging scenarios, it is convenient to use embedded OpenMQ broker, which is available by default. However, this embedded OpenMQ is running inside the JVM instance of Payara Server. This implies that whenever one of them needs to be restarted, the other one gets restarted too.
We've seen reports of messages sometimes getting stuck inside the embedded OpenMQ broker and only getting processed after restarting whole Payara Server. This is not reasonable in more complex use cases with high availability in mind. Most often when clustering is involved, it is worth considering other options of running OpenMQ.
There are 3 modes for GlassFish to use OpenMQ: EMBEDDED, LOCAL and REMOTE. There is some overlap in what is involved with each of these. Section 10-2 of the official GlassFish Server Open Source Edition 4.0 High Availability Administration Guide gives the following definitions:
EMBEDDED | Conventional broker cluster with master broker (default) Conventional broker cluster of peer brokers |
LOCAL | Conventional broker cluster with master broker (default) Conventional broker cluster of peer brokers Enhanced broker cluster |
REMOTE |
Conventional broker cluster with master broker
|
Note that there are 2 more modes: LOCAL and REMOTE.
Both of them provide an additional option to use Enhanced broker cluster, which is more robust and guarantees 100% data availability and recovery at failover.
LOCAL mode means that OpenMQ broker is located on the same host as Payara Server instance. This is easier to manage, but the number of OpenMQ instances needs to be the same as number of Payara Server instances, making it impossible to scale them independently of each other.
REMOTE instances of OpenMQ need to be managed separately from Payara server instances, however, they can differ in number. Adding new instance of Payara server into the cluster does not require additional instance of OpenMQ broker.
A separate remote OpenMQ broker can be started using the imqbrokerd
command in the mq/bin
directory inside Payara Server installation.
Useful note |
Specify
The remedy is to use the command like the following (which also overrides the default port of 7676):
|
To shutdown OpenMQ, use the following command in Payara Server installation:
mq/bin/imqcmd shutdown bkr [-b host:port]
Payara Server installation comes with reasonable defaults to enable wide range of functionality out of the box without additional configuration. This also includes embedded OpenMQ broker, ready to be used immediately. However, LOCAL and REMOTE modes of running OpenMQ are also available. We highly encourage to switch to them in production deployments, especially when high availability is required. To improve reliability with recovery at failover, it is worth to consider using Enhanced broker cluster with LOCAL or REMOTE mode.
Related Posts
Continuous Integration and Continuous Deployment for Jakarta EE Applications Made Easy
Published on 25 Mar 2024
by Luqman Saeed
0 Comments
Easy Jakarta EE Integration Testing with the Payara Platform and Testcontainers
Published on 24 Mar 2022
by Fabio Turizo
0 Comments