The purpose of this guide is to get you started on the main features of WSO2 Message Broker (MB) as quickly as possible. We will create queues and topics on WSO2 MB and then see how JMS clients can send messages to these queues/topics and receive messages from them.
Key concepts
Explained below are some of the key concepts in message brokering.
Queues
Queues in WSO2 MB are essentially message stores, which can store messages from external JMS clients (publishers) and maintain them in an intermediate state until they are consumed by other JMS clients (subscribers).
Topics
Topics in WSO2 MB are used for realtime message brokering. As depicted by the following diagram, you can maintain a hierarchy of topics or subjects in MB for which messages can be published by external JMS clients (publishers). Other JMS clients (subscribers) can subscribe to the topics of interest and receive the messages published to the topic.
Subscribers and Publishers
A JMS client that is configured to send messages to a queue or topic is known as a publisher. A JMS client that is configured to receive messages published to a particular queue or topic is known as a subscriber.
Management Console
The management console of WSO2 MB is the user interface of the product, which can be used to conveniently create topics and queues and to manage subscriptions. External clients can then connect to WSO2 MB for publishing messages and consuming already published messages.
Before you begin
Install WSO2 MB and download JMS clients as explained below.
Download and start WSO2 MB
Follow the steps given below to download and start a WSO2 MB instance.
- Download WSO2 Message Broker from here.
- Extract the ZIP file to a location on your computer. This location will be referred to as
<MB_HOME>
from hereon. - To start the product: Open a terminal, navigate to the
<MB_HOME>/bin
directory where all the startup scripts are stored and run the startup script:- On Windows:
wso2server.bat
- On Linux:
sh wso2server.sh
- On Windows:
The URL of the management console will be printed in the terminal as follows:
INFO {org.wso2.carbon.ui.internal.CarbonUIServiceComponent} - Mgt Console URL : https://10.100.5.65:9443/carbon/
Download sample JMS clients
WSO2 Message Broker is used for brokering messages between JMS clients. We will use the following sample JMS clients in this quick start guide to see how this process works.
- Click this link to download the
QuickStartClients.zip
file, which contains the following sample clients.- JMS queue publisher
- JMS queue subscriber
- JMS topic publisher
- JMS topic subscriber
- JMS durable topic subscriber
- Extract this file to a location on your computer. We will call this
<JMS_CLIENTS_HOME>
from hereon.
You will need Apache Ant to execute the above JMS clients. Download Apache Ant using homebrew.
Working with Queues
Let's try out a simple scenario of brokering messages using a queue in WSO2 MB.
Step 1: Create a queue in WSO2 MB
We will now create a queue in WSO2 MB, using the product's management console. Follow the instructions given below.
- Log in to the management console using the credentials of the default system administrator: admin/admin.
You will now be logging into the super tenant domain. - In the Main tab, click Queues -> Add. The Add Queue screen will open.
- Enter 'testQueue' as the name in the Queue Name field as shown below.
- Click Add Queue and the new queue will be listed in the Queue List page as shown below.
You can access the Queue List page by clicking Queues -> List in the Main tab of the navigator.
Step 2: Publish messages to the queue
You can use the queue publisher JMS client to publish messages to this queue. Follow the steps given below.
- Open a command prompt and navigate to the
<JMS_CLIENTS_HOME>
directory on your computer. Execute the following command, which will publish 10 messages to the queue:
ant queuePublisher
- Go to the management console.
- In the Main tab, click Queues -> List. You can see that 10 messages have been published to the queue as shown below.
- Click Browse to see details of the messages received.
Step 3: Subscribe to the queue and consume messages
The queue subscriber JMS client will be used for this purpose. Follow the steps given below.
- Open a command prompt and navigate to the location of your JMS clients.
Execute the following command, which will subscribe to the queue and consume the available messages.
ant queueSubscriber
- Go to the management console.
- In the Main tab, click Queues -> List. You can see that the 10 messages that were stored in the queue have been successfully consumed by the subscriber.
- You can verify this from the terminal log.