At Solace we are always on the lookout for innovative products and tools related to messaging. We love open source and contribute where we can. We were delighted to discover JMSToolBox, a very useful JMS client. When we first discovered it, JMSToolBox had the capability to connect with more than a dozen JMS providers, but not Solace. Now we are happy to say that you can use JMSToolBox to perform a variety of tasks with our PubSub+ event brokers via the JMS API.
The features JMSToolBox provides are well documented on its website, so we will not repeat them all here. But the features we find really useful are:
Let us imagine we are developing an event-driven application for a burger joint, Zoe’s Burgers. They have a couple of order takers at the front and a few cooks at the back. When they take an order, their POS system sends a message to a topic named “orders” on the JMS provider. We need the messages to go to two places: the cooks in the kitchen and a back office for record keeping purposes. Therefore, we will create two queues, one called “kitchen” and one called “office.” Both queues subscribe to the “orders” topic.
Zoe’s picked Solace because although our free standard edition of PubSub+ Event Broker gives them more than enough performance and reliability, once they grow to the point where they are selling tens of millions of burgers per second, our enterprise products will be able to keep up without breaking a sweat.
In order to test if the message broker is set up properly, we want to send messages to the “orders” topic and confirm that the messages appear on both queues. This is the kind of job that JMSToolBox is great for. We will start by creating a new Solace session by double clicking the Solace entry from the list of queue managers:
Then we enter the connection properties. Note that “User id” is the client username.
We also have to enter the Message VPN name and management credentials. The latter are necessary for retrieving the list of queues (this might become unnecessary in a later release.) You can see that there are fields to enter SSL properties if required, though you don’t need to do that if you are simply using the secure connection properties provided by Solace PubSub+ Event Broker: Cloud.
Once we are connected, we see the queues and the topic in the session view. Note that we also have an ActiveMQ session. Later we will use it to show how to share messages between JMS providers.
JMSToolBox provides a feature that lets you create templates for creating messages. If you look at the Templates pane, you will see that we have created a couple of templates called “order” and “order-csv”:
If you open up the “order” template, you can see that it is a text format message with a JSON payload:
The payload contains a variable for the value of the first field. JMSToolBox has some predefined variables, including currentTimestamp which we use here. It provides other ones that can generate random numbers and strings.
To use this template, we right-click the topic and select “Send Message from Template”. Once we have done that, we should be able to see the message on both of our queues. We can double-click the “kitchen” queue and we will see the following:
If we select the message, we can see the payload:
You can see that the first field has been replaced by an actual timestamp, and we can verify that the office queue also has this message by double-clicking on that queue. Text format messages can be viewed directly in JMSToolBox, but when you have messages in proprietary binary formats, you can plug in a ‘message visualizer’ to get JMSToolBox to run an external program that knows how to display your message.
What if we want to send lots of messages each with different data? JMSToolBox has a scripting feature that can do that.
First, we create a comma-separated-value file. We will call our template “orders.csv” and it will have the following contents:
Each line contains one order. To keep things simple, we will assume each order only has one item. The first field is the order id, the second is the item, and the third is the total cost.
Here we have opened the JMSToolBox Script Manager window and selected the “orders” script we created earlier:
A script can have several steps, but this “orders” script has just one step, which is to iterate over the csv file and send a message for each line. As you can see, it specifies the template to use (order-csv), the session (solace), the destination (orders), and the data file. If you click the Data Files tab, you will see the following:
Here we have specified one data file. We can use the Variable Prefix and Variable Names entries in our message template to refer to the data in the csv file. The variable names refer to the fields on each line, in order, so “id” is the first value on a line, “item” is the second value, and “total” is the third.
We have created a second template for this purpose that looks like this:
This shows how to refer to data in the csv file in the template. Now we go back to the Scripts window and hit the Execute button. If we view the messages in the queues, we will see there are four (three new ones and the one we created earlier), and the last one looks like this:
Suppose we want to copy the messages to a different JMS provider or to another queue within the same provider. Here I have opened the ActiveMQ session and selected the orders queue. It is currently empty:
We can simply drag and drop the messages from our “kitchen” queue to the ActiveMQ “orders” queue, and JMSToolBox will send them over:
We can use the same procedure to copy messages from one queue to another within the same provider.
The final feature we will discuss is its REST interface. The REST interface can be used to list the destinations of a session, to send or retrieve messages, empty queues, and so on. This opens the door for all kinds of automation use cases. For example, one could write a script that:
JMSToolBox is a tremendously useful tool especially for its scripting and automation capabilities. At Solace we are grateful for the opportunity to contribute to the project and we hope to continue collaborating with the developer and the community.
Watch the “JMSToolBox Now Supports Solace PubSub+” video to learn more about JMSToolBox and Solace. Have questions? Post them to the Solace Developer Community.