Apache ActiveMQ is an open source message broker that is developed in Java and with a full Java Message Service (JMS) client. As oriented for enterprise use cases, it supports multiple Java standards, languages and protocols:
- JMS 1.1, J2EE 1.4, JCA 1.5 and XA
- Java, C, C++, C#, Ruby, Perl, Python, PHP
- TCP, SSL, NIO, UDP, multicast, JGroups and JXTA transports
In this blog, I would like to introduce how to deploy ActiveMQ on OneOps.
First, choose ActiveMQ
pack in the Design phase.
For the demonstration purpose, in activemq
component, we could keep everything default, but Auth Type
set to None
, such as following,
In more serious cases, JAAS
or other authentication methods should be used.
There are also two optional components: queue
and topic
that could be added upfront or later when needed. It is highly to recommended to create/edit/delete queue
and topic
in the OneOps layer. This is because: (1) take advantage of the OneOps audit trail so that we know which changes have been made. (2) more statistics about the topic or queue (e.g. message in/out per second, pending messages per second) could be provided and visualized on OneOps UI.
Last, we could add our own SSH key to the user-activemq
component so that we could log into the VM later on.
Commit the design and we are ready to deploy ActiveMQ. Create a new environment with Availability Mode = single
and 1 cloud as primary cloud, as ActiveMQ is not a distributed system by its nature and the current ActiveMQ pack did not fully support a High Availability (HA) deployment out-of-the-box. It may be the future work to have the pack support some Master-Slave deployment.
The deployment plan may resemble as following,
After the deployment, we could SSH into the ActiveMQ broker and run a simple JMS program to test the ActiveMQ.
On the broker machine, download the hello world JMS code and save it as App.java
, then use an editor to change the following from
ActiveMQConnectionFactory("vm://localhost");
To
ActiveMQConnectionFactory("nio://0.0.0.0:61616");
Save the change and compile the code by: javac -cp /opt/activemq/activemq-all-5.13.0.jar App.java
Then run the code by: java -classpath /opt/activemq/activemq-all-5.13.0.jar:. App
The output of the code run would be:
Sent message: 140686497 : Thread-0
Sent message: 104414848 : Thread-1
Received: Hello world! From: Thread-23 : 2112836430
Sent message: 125493280 : Thread-9
Sent message: 1026563844 : Thread-6
Received: Hello world! From: Thread-0 : 1499689553
Received: Hello world! From: Thread-6 : 336615606
Received: Hello world! From: Thread-9 : 1948548290
Sent message: 907776190 : Thread-17
Sent message: 645246177 : Thread-16
Sent message: 1998048735 : Thread-12
Received: Hello world! From: Thread-30 : 1818405427
Received: Hello world! From: Thread-9 : 574906110
Sent message: 1335593353 : Thread-19
Sent message: 1799775865 : Thread-25
Sent message: 935344593 : Thread-30
Sent message: 1964711431 : Thread-23
Received: Hello world! From: Thread-0 : 1694803203
Received: Hello world! From: Thread-19 : 686363848
Sent message: 271300696 : Thread-27
Received: Hello world! From: Thread-25 : 2112836430
Received: Hello world! From: Thread-23 : 756278511
Received: Hello world! From: Thread-1 : 321452604
Received: Hello world! From: Thread-25 : 523145999
The above output shows that ActiveMQ broker is working properly.
Another place to check ActiveMQ is through its web admin console. Open a browser and enter
. The http://platform_level_fqdn_or_ip:8161/admin
could be retrieved from the these steps: go to platform_level_fqdn
Operate
phase, click your_activemq_platform_name
on the right, find fqdn
component and click into, the shorter URL is
.platform_level_fqdn
The browser will have a pop-up window to ask for username and passwords, which are admin
by default.
After logging into the web admin console, the main page should look like:
We could further check the information of the queue that is just created for the “hello world” JMS code.
Monitoring & Alerting
In Operate
phase, some statistics about ActiveMQ broker could be visualized on OneOps UI. For example, for an ActiveMQ instance, click to Operate
Tab, which will show the following 3 items to monitors:
The BrokerStatus
shows some broker related statistics:
The Memory Status
shows some memory related statistics on the broker:
The Log
will alert if there is some critical log exception in the ActiveMQ broker log file, within 15 minutes.
Summary
Here is a more detailed user guide about ActiveMQ pack on OneOps, especially for setting up SSL, authorization and authentication. To make it better for production, the future work may be to add clustering to support HA and Disaster Recovery.