📜 ⬆️ ⬇️

IBM MQ and JMeter: First Contact

Hi, Habr!

This is a prequel of my previous publication and at the same time a remake of the article Automated testing of services using the MQ protocol using JMeter .

This time, I’ll talk about my experience of reconciling JMeter and IBM MQ for happy testing applications on IBM WAS. Faced such a task, she did not easily give in. I want to help save time for all interested.


Introduction


About the project: data bus, multiple xml messages, three exchange areas (queues, databases, file system), web services with their own message processing logic. As the project progressed, testing by hand became increasingly difficult. Apache JMeter was called to help - powerful and open source, with a large user community and user-friendly interface. The ease of customization of the "out of the box" version allows you to cover any cases, and the promise of the lead developer to help if that (did help) finally approved the choice.

Preparing the initial context


To interact with the queue manager, you need an initial context. It is of several types, here you can read more.
To create it is convenient to use MQ Explorer:


Figure 1: Adding an initial context

Select the context file type and the directory for storing the .bindings file, which will contain the description of JNDI objects:


Figure 2: Select the type of initial context

Then you can start creating these objects. And start with the connection factory:


Figure 3: Creating a connection factory

Choose a friendly name ...


Figure 4: Choosing the name of the connection factory

... and type Queue Connection Factory :


Figure 5: Selecting the connection factory type

Protocol - MQ Client to communicate with MQ remotely:


Figure 6: Selecting the connection factory protocol

In the next step, you can select an existing factory and copy further settings from it. Click Next , if there is none:


Figure 7: Choosing settings for an existing connection factory

In the parameter selection window, just set three. On the Connection tab, specify the name of the queue manager and stand ip with its location (leave port 1414 ):


Figure 8: Configuring the connection factory settings

And on the Channels tab - the channel for the connection. Click Finish to complete:


Figure 9: Completing the connection factory

Now create a connection to the queue:


Figure 10: Creating a target

Choose a friendly name (I prefer to specify the real name of the queue) and type Queue :


Figure 11: Selecting the name and type of target

Similar to Figure 7, you can copy settings from an existing queue. Also click Next if it is the first:


Figure 12: Selecting Present Target Settings

In the settings window, just select the name of the manager and the desired queue, click Finish . After that, repeat the required number of times until all the queues necessary for interacting with JMeter are created:


Figure 13: Completing the creation of the target object

JMeter preparation


Preparing JMeter is to add the libraries necessary to interact with MQ. They are located in% wmq_home% / java / lib. Copy them to% jmeter_home% / lib / ext before running JMeter.



An alternative list suggested by polarnik in a comment with a slight nuance: javax.jms-api-2.0.jar instead of jms.jar.
With jms.jar, the error NoClassDEfFoundError occurs, the solution of which is found here .



Both library lists work successfully with JMeter 5.0 and IBM MQ 8.0.0.4.

Setting up a test plan


The necessary and sufficient set of JMeter elements is as follows:


Figure 14: Test Plan

In the sample test plan, there are five variables. Despite the small number of them, I recommend having separate configuration elements for different types of variables. As the test grows, this will greatly simplify navigation. In this case, there are two lists. The first one contains the parameters for connecting to MQ (see Figure 2 and Figure 4 ):


Figure 15: MQ Connection Settings

The second is the names of targets that refer to queues:


Figure 16: Parameterized Queue Names

It remains to configure JMS Publisher to load the test message into the outgoing queue:


Figure 17: Configuring JMS Publisher

And JMS Subscriber to read the message from the incoming queue:


Figure 18: Configuring JMS Subscriber

If everything is done correctly, the result of the execution in the listner will be filled with bright and cheerful green colors.

Conclusion


Intentionally lowered the issues of routing and administration, it is quite intimate and extensive topics for individual publications.

In addition, there is a solid portion of the nuances in working with queues, databases and files, which I would also like to talk about separately and thoroughly.

Take care of your time. And thank you for your attention.

image

Source: https://habr.com/ru/post/437172/