Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Active MQ - Local machine JMS Point to Point and Publisher Subscriber model | Windows 11

Demonstration on the working of ActiveMQ JMS (Java Message Service) methods using Java JFrame. The application is designed to understand the working of point to point and publisher subscriber model of JMS using active mq server.

Java Application

Screenshot 2022-03-17 223530

Steps to execute:

Step 1: Activate ActiveMQ - Download ActiveMQ from https://activemq.apache.org/components/classic/download/ and under bin folder run "/win32/activemq.bat" or "/win64/activemq.bat" based on your operating system. Once the command prompt returns the following message, you can proceed on working with JMS models.

Screenshot 2022-03-17 224026

Note: ActiveMQ version 5.16.4 is used in this project.

Step 2: Open web browser and navigate to "http://localhost:8161/admin". Username and Password is "admin". Once logged in, you will be able to see ActiveMQ console where you will be able to track the information on Topics, Active subscribers, Queueing of messages etc.,

Screenshot 2022-03-17 224625

Step 3: NetBeans IDE is used for better visualization of the application using JFrame. Get the NetBeans IDE from "https://netbeans.apache.org/download/index.html".

Step 4: Download the project files. If necessary, replace the file "san_activemq\lib\activemq-all-5.16.4.jar" with latest "activemq-all-.jar" file version you need.

Step 5: Open san_activemq\src\activeMQJFrame\MainFrame.java using NetBeans IDE and Run the project.

Note: ActiveMQ must be running at the background to successfully send or receive messages.

Working:

Point to Point model :

Refer "sendP2PActionPerformed" and "activateReceiverActionPerformed" in MainFrame.java

The message sent by the "point to point" sender is enqueued into the Queue. The message can only be received by an receiver, if the receiver holds the same "Service name" as the sender. Once a receiver with same service name is activated, the message is dequeued from the queue and the receiver receives the message.

Under Sender Tab -> Point to Point -> Enter the message you would need to send (Remember the service name is "Queue") -> Hit "Send Message".

image

In the output menu in Netbeans -> It must look something like this -> image

Now under Receiver Tab -> Point to Point -> Activate Receiver (Remember the receiver also holds the same service name "Queue")

image

Note: In Point to Point method, the receiver need not be in active state to receive messages, as the message is available in the queue that is later sent once the receiver gets activated. It is not the same sceenario in Publisher subscriber model.

Publisher Subscriber model :

Refer "subscribeAndActivateActionPerformed" and "sendSubMessageActionPerformed" in MainFrame.java

For Subscription model, there will be many users subscribed to a topic with which they receive messages. Similar to how we receive mails from promotional websites, we are the subscribers who might have subscribed to receive updates from the promotional websites such as Job updates.

Under Receiver tab -> Subscription -> Enter the User name and Topic to which they are interested to receive messages on -> Hit "Subscribe" (The User and his interest of Topic is added into the activeMQ server)

image

Under Sender tab -> Subscription -> Enter the Topic name with which the sender needs to send messages -> Enter the message you need to send to users interested in that particular topic -> Hit "Send Message"

image

You can notice that there are two users, who are Subscribed to topic named "VIT". As soon as the sender sends a message for users subscribed to the particular topic, the subscribers receive message.

Note: In Publisher Subscriber model, the subscribers need to be in active state to receive messages. In this application, as soon as there is user subscribing to a particular topic, they are in active state. That is how, the received messages for actively subscribed users are stacked in the tabular column.

Sample Screenshot :

image

Other Reference : https://www.tomitribe.com/blog/5-minutes-or-less-activemq-with-jms-queues-and-topics/

About

Demonstration on the working of ActiveMQ JMS (Java Message Service) methods using Java JFrame.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages