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 contextSelect 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 contextThen you can start creating these objects. And start with the connection factory:
Figure 3: Creating a connection factoryChoose a friendly name ...
Figure 4: Choosing the name of the connection factory... and type
Queue Connection Factory :
Figure 5: Selecting the connection factory typeProtocol -
MQ Client to communicate with MQ remotely:
Figure 6: Selecting the connection factory protocolIn 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 factoryIn 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 settingsAnd on the
Channels tab - the channel for the connection. Click
Finish to complete:
Figure 9: Completing the connection factoryNow create a connection to the queue:
Figure 10: Creating a targetChoose a friendly name (I prefer to specify the real name of the queue) and type
Queue :
Figure 11: Selecting the name and type of targetSimilar to
Figure 7, you can copy settings from an existing queue. Also click
Next if it is the first:
Figure 12: Selecting Present Target SettingsIn 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 objectJMeter 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.
- com.ibm.mq.commonservices.jar
- com.ibm.mq.headers.jar
- com.ibm.mq.jar
- com.ibm.mq.jmqi.jar
- com.ibm.mq.pcf.jar
- com.ibm.mqjms.jar
- dhbcore.jar
- fscontext.jar
- jms.jar
- jta.jar
- providerutil.jar
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 .
- com.ibm.mq.allclient.jar
- fscontext.jar
- javax.jms-api-2.0.jar
- providerutil.jar
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 PlanIn 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 SettingsThe second is the names of targets that refer to queues:
Figure 16: Parameterized Queue NamesIt remains to configure JMS Publisher to load the test message into the outgoing queue:
Figure 17: Configuring JMS PublisherAnd JMS Subscriber to read the message from the incoming queue:
Figure 18: Configuring JMS SubscriberIf 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.