WebSphere MQ overview
WebSphere MQ formerly known as MQ Series is IBM’s enterprise messaging solution. In a nutshell, MQ provides the mechanisms for messaging both in point-to-point and publish-subscribe. However, it guarantees to deliver a message only once. This is important for critical business applications which implement messaging. An example of a critical system could be a banking payments system where messages contain messages pertaining to money transfer between banking systems, so guaranteeing delivery of a debit/credit is paramount in this context. Aside from guaranteed delivery, WMQ is often used for messaging between dissimilar systems and the WMQ software provides programming interfaces in most of the common languages, such as Java, C, C++, and so on. If you are using WebSphere, then it is common to find that WMQ is often used with WebSphere when WebSphere is hosting message-enabled applications. It is important that the WebSphere administrator understands how to configure WebSphere resources so that application can be coupled to the MQ queues.
Overview of WebSphere MQ example
To demonstrate messaging using WebSphere MQ, we are going to re-configure the previously deployed JMS Tester application so that it will use a connection factory which communicates with a queue on a WMQ queue manager as opposed to using the default provider which we demonstrated earlier.
Installing WebSphere MQ
Before we can install our demo messaging application, we will need to download and install WebSphere MQ 7.0. A free 90-day trial can be found at the following URL:
Click the download link as shown below.
You will be prompted to register as an IBM website user before you can download the WebSphere MQ Trial. Once you have registered and logged in, the download link above will take you to a page which lists download for different operating systems.
Select WebSphere MQ 7.0 90-day trial from the list of available options as shown below.
Click continue to go to the download page. You may be asked to fill out a questionnaire detailing why you are evaluating WebSphere MQ (WMQ). Fill out the question as you see fit and submit to move to the download page.
As shown above, make sure you use the IBM HTTP Download director as it will ensure that your download will resume, even if your Internet loses a connection.
If you do not have a high-speed Internet connection, you can try downloading a free 90-day trial of WebSphere MQ 7.0 overnight while you are asleep.
Download the trial to a temp folder, for example c:temp, on your local machine. The screenshot above shows how the IBM HTTP Downloader will prompt for a location where you want to download it to. Once the WMQ install file has been downloaded, you can then upload the file using an appropriate secure copy utility like Winscp to an appropriate folder like /apps/wmq_install on your Linux machine. Once you have the file uploaded to Linux, you can then decompress the file and run the installer to install WebSphere MQ.
Running the WMQ installer
Now that you have uploaded the WMQv700Trial-x86_linux.tar file on your Linux machine, and follow these steps:
- You can decompress the file using the following command:
- Then run the un-tar command:
tar -xvf ./ WMQv700Trial-x86_linux.tar
- Before we can run the WMQ installations, we need to accept the license agreement by running the following command:
- To run the WebSphere MQ installation, type the following commands:
rpm -ivh MQSeriesRuntime-7.0.0-0.i386.rpm
rpm -ivh MQSeriesServer-7.0.0-0.i386.rpm
rpm -ivh MQSeriesSamples-7.0.0-0.i386.rpm
- As a result of running the MQSeriesServer installation, a new user called mqm was created. Before running any WMQ command, we need to switch to this user using the following command:
su - mqm
- Then, we can run commands like the dspmqver command which can be run to check that WMQ was installed correctly. To check whether WMQ is installed, run the following command:
The result will be the following message as shown in the screenshot below:
Creating a queue manager
Before we can complete our WebSphere configuration, we need to create a WMQ queue manager and a queue, then we will use some MQ command line tools to put a test message on an MQ queue and get a message from an MQ queue.
- To create a new queue manager called TSTDADQ1, use the following command:
- The result will be as shown in the image below.
- We can now type the following command to list queue managers:
- The result of running the dspmq command is shown in the image below.
- To start the queue manager (QM), type the following command:
- The result of starting the QM will be similar to the image below.
- Now that we have successfully created a QM, we now need to add a queue called LQ.Test where we can put and get messages.
- To create a local queue on the TSTDADQ1 QM, type the following commands in order:
- You are now running the MQ scripting command line, where you can issue MQ commands to configure the QM.
- To create the queue, type the following command and hit Enter:
- Then immediately type the following command:
- Hit Enter to complete the QM configuration, as shown by the following screenshot.
You can use the following command to see if your LQ.TEST queue exists.
echo "dis QLOCAL(*)" | runmqsc TSTDADQ1 | grep -i test
You have now added a local queue called Q.Test to the TSTDADQ1 queue manager.
DEFINE LISTENER(TSTDADQ1.listener) TRPTYPE (TCP) PORT(1414)
You can type the following command to ensure that your QM listener is running.
ps -ef | grep mqlsr
The result will be similar to the image below.
To create a default channel, you can run the following command.
DEFINE CHANNEL(SYSTEM.ADMIN.SVRCONN) CHLTYPE(SVRCONN)
We can now use a sample MQ program called amqsput which we can use to put and get a test message from a queue to ensure that our MQ configuration is working before we continue to configure WebSphere.
Type the following command to put a test message on the LQ.Test queue:
/opt/mqm/samp/bin/amqsput LQ.TEST TSTDADQ1
Then you can type a test message: Test Message and hit Enter; this will put a message on the LQ.Test queue and will exit you from the AMQSPUTQ command tool.
Now that we have put a message on the queue, we can read the message by using the MQ Sample command tool called amqsget. Type the following command to get the message you posted earlier:
/opt/mqm/samp/bin/amqsget LQ.TEST TSTDADQ1
The result will be that all messages on the LQ.TEST queue will be listed and then the tool will timeout after a few seconds as shown below.
We need to do two final steps to complete and that is to add the root user to the mqm group. This is not a standard practice in an enterprise, but we have to do this because our WebSphere installation is running as root. If we did not do this, we would have to reconfigure the user which the WebSphere process is running under and then add the new user to MQ security. To keep things simple, ensure that root is a member of the mqm group, by typing the following command:
usermod -a -G mqm root
We also need to change WMQ security to ensure that all users of the mqm group have access to all the objects of the TSTDADQ1 queue manager. To change WMQ security to give access to all objects in the QM, type the following command:
setmqaut -m TSTDADQ1 -t qmgr -g mqm +all
Now, we are ready to re-continue our configuring WebSphere and create the appropriate QCF and queue destinations to access WMQ from WebSphere.