Java Messaging Service – Part 2 – Setup ActiveMQ
In this blog article, we will see setting up ActiveMQ JMS provider in the local machine. We will also Create a new queue destination and send a message to the queue. Finally, we will setup an optional web console hawtio to administer the ActiveMQ
It is recommended to visit the previous article on JMS series –
What is JMS?
It is a Java Message oriented middleware (MOM) API that supports sending messages between two or more systems.
What is ActiveMQ?
– It is an Open source, Java-based JMS provider.
– It supports industry standard protocol for JMS.
Get to know more about ActiveMQ at the following link – http://activemq.apache.org/
How to setup ActiveMQ in a local machine (Windows)?
Step 1: Download the ActiveMQ binaries.
Visit the following link – https://activemq.apache.org/components/classic/download/ Download the latest version zip.
Step 2: Extract the binaries in your local machine.
Step 3: Start the ActiveMQ server.
Switch to the bin folder.
C:MyInstallapache-activemq-5.15.12-binapache-activemq-5.15.12bin
Execute the script.
.activemq start
You should see the success message in the logs.
You see ActiveMQ Web Console is available at port 8161.
Launch the portal – http://localhost:8161
Use the Admin console to administer the ActiveMQ.
You can provide the username/password – admin/admin
How to create a new queue and send a message?
Step 1: Navigate to the Queues tab.
Step 2: Provide a new Queue Name and click Create.
You will see the newly created queue.
Step 3: Send a new message to the queue.
On the Operations, click on Send To.
You see the configuration screen to set the message headers and body to send a new JMS message.
Click on Send.
You will see a new message queued.
We have successfully created the first message in our JMS queue.
To have some more administration on ActiveMQ, I would like to use a new web application – Hawtio. Feel free to skip the below step if not required.
What is Hawtio?
Hawtio is a web console for managing Java applications.
Visit the link for more details – https://hawt.io/docs/
Let’s straightaway setup the hawtio in our Tomcat server.
How to setup Hawtio in your local Windows machine?
Step 1: Download the war file.
Click on the link – https://github.com/hawtio/hawtio/releases/tag/hawtio-2.10.0
Rename the war file to remove the hyphen.
Step 2: Place the war file in the Pega personal edition tomcat webapps directory.
By this way, the Tomcat server will be hosting the third web application in addition to prweb and prhelp.
Step 3: Start the tomcat server (Pega personal edition server)
Once the server restarted, launch the portal for hawtio
You will prompted with username/password – admin/admin
Step 4: establish the connection with the ActiveMQ
Do a test connection.
You should see a successful connection established.
Step 5: Click on the connect button on the right
You will see the details of the connection on the landing page.
You also see the newly created Queue – MyKnowPega.FirstQ.
So here we set up a destination path for the Queue.
You can play around with hawtio to send messages to the queue.
In the next article, we will see how to administer Pega to connect to Active MQ.