Informing the IBM Community

0
(0)

I’ve got a little home project that I’ve been looking at for a while.  In this article, I’ll prepare our IBM i for that project.

It will involve some IoT devices sending data to the IBM i.

To receive that information the IBM i, will be using the Open Source package ActiveMQ.

What is ActiveMQ?

Simply put, ActiveMQ is a message service to send data between applications and systems, and yes, it is open-source.

It is a widly popular and very reliable message broker.

It allows us to connect from nearly everything to nearly everything, including our IBM i.

Basically, ActiveMQ sends messages between client applications.

ActiveMQ, provided by Apache, is a middleware messaging service, that is very similar to the very popular WebSphere MQ product from IBM.  If you are familiar with WebSphere MQ you will have no problem using ActiveMQ.

For detailed documentation about ActiveMQ, check out the offical site at https://activemq.apache.org/

MQTT Protocol

Before we move onto using this product, it is worth mentioning MQTT.

One of the many ActiveMQ protocols ActiveMQ can use is MQTT. 

MQTT is the most used messaging protocol for Internet of Things (IoT) devices.

MQTT stands for MQ Telemetry Transport.  This protocol is a set of rules that defines how IoT devices can publish and subscribe to data across our network.

We will be using this protocol during this project.

ActiveMQ Terminology

If you are not familiar with the terms that ActiveMQ uses, take a look at the table below to give you some ideas about what we are going to cover. 

They are very similar to the terminology used in IBMs messaging middleware.

Publish/subscribe, also known as pub/sub, allows services to communicate asynchronously.  Publishers communicate with subscribers by broadcasting events, rather than direct synchronous calls.

By separation, it makes applications more robust and can simpify software development.

The publisher (sender) does not need to know if the subscriber (receiver) is up and running.  Also, the publisher does not need to know how many subscribers, or which subscribers, need to receive the message.

ActiveMQ Commands

If you are not familiar with the commands that ActiveMQ uses, take a look at the table below to give you some ideas about what we are going to cover. 

Installing ActiveMQ

As I’ve already said, ActiveMQ is open source and made available from IBM using the usual RPMs.

So, it can be installed via the Open-Source Package Management from ACS (Access for Client Solutions) or by using YUM via a PASE SSH session.

The screen shot below shows the installation of ActiveMQ using YUM.

Starting ActiveMQ

Going back to our shell PASE session, starting ActiveMQ is simple.  Use the command below to start the service.

activemq start

If the product installed without any issues, you should see the informational messages as seen in the figure below.

And that is all it takes to start ActiveMQ.

To check the status of ActiveMQ, run the status command.

ActiveMQ status

To ensure that ActiveMQ is running constantly, consider using the excellent Service Commander product to automatically start it.

If you don’t know all about Service Commander, check out my PowerWire article at the link https://powerwire.wpengine.com/service-commander-on-ibm-i  with the GitHub repository at https://github.com/ThePrez/ServiceCommander-IBMi Give it a try!

Using ActiveMQ

Once you have started the ActiveMQ server, it is accessed via your favourite browser, and runs on port 8161. 

Point your browser at your_IBMi:8161 and the ActiveMQ web console home page will be displayed.

If asked for a userID and password, use admin/admin.

If your page does not render, consider using Service Commanders Open Ports (scopenports) command to check if the ActiveMQ port (8161) is active.

When you are on the home page, take the option to Manage ActiveMQ Broker.

Then the following page is displayed.

All looking good so far!

Testing Queues and Topics

To prove our installation, we must test both queues and topics.

Firstly, create a new queue and send data to that queue.

In our ActiveMQ browser session, select the Queues tab, just enter the name of your new queue and press the Create button.

Here, we can see the queue we created.

We now have our first queue, with a name of Testing, we need to send some data to that queue.

Take the link to Send To on the right-hand side of the queue name.

On the next screen, fill in the message you wish to send to this queue.

  1. Destination, already specified
  2. Queue, already populated
  3. Input the test message body
  4. Press the Send button

Our queue now has our message there.

That has proved that the queues feature worked fine and is ready to accept messages.

Now onto testing topics

Firstly, I will create a ActiveMQ topic.  To do this, I’ll still use my browser session.

  1. Select the Topics Tab
  2. Enter the name of the new Topic, in this case PowerWire
  3. Hit the Create button.

To test the topics feature, I’ll be using VSCode to test. 

I’m amazed at the versatility of this great product.  It seems whatever I need these days, there is a Visual Studio Code extension for it!  We should all be thanking Microsoft for building the foundation of this great product.

On firing up Visual Studio Code, we head to the extensions and search for a MQTT extension that will allow us to test our ActiveMQ connection.

Searching for MQTT, the protocol we will be using, brings up three extensions at this time.  There may be more than this by the time you search.

I’ve installed the VSMQTT extension, although I’m sure the other two will do a great job.

Then use the system palette (F1) to input the configuration details for our IBM i called Galatea.

Use the plus sign alongside the VSMQTT profile and it will take you through the items the configuration needs.

In the figure above you can see I’ve already configured a VSMQTT profile named Galatea IBMi.

The details I provided are shown in the figure below

Firstly, let me subscribe to the PowerWire topic in VS Code called PowerWire.

  1. Enter PowerWire as the Subscribe To Topic
  2. Press the Subscribe button to execute the subscription, then we can see the subscription in the green box

Once we have subscribed to the PowerWire subscription/topic, we can send/publish messages

  1. In the publish section, we enter the name of our subscription, which is PowerWire
  2. The message we want to send. 
  3. Click the publish button
  4. Our messages are shown after the Publish button has been pressed

Going back to the ActiveMQ console we can see the PowerWire topic with one message.

Conclusion

That has tested our ActiveMQ installation from my PC, via VS Code and internally from a browser, to the IBM i.  We are now ready to move onto the next part of this project.

In my next article for PowerWire, I’ll be sending messages to ActiveMQ on our IBM i. It will be using the popular MQTT protocol from an IoT device – should be interesting!

All the examples I have written for this article, and previous ones, can be found on my open-source repository on GitHub, which can be found at https://github.com/formaserve/f_Learning

If you have any questions, either on this article, or anything else on the IBM i, use the comments below, or send me a message on twitter @AndyYouens

Andy Youens is an IBM i consultant/instructor at Milton Keynes, UK-based FormaServe Systems with over 40 years IBM midrange experience. 

IBM Champion

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *