In this blog post I will describe how to use Apache JMeter to publish and subscribe to a queue via WSO2 Message Broker.
Step 1 - Download Apache JMeter
Download Apache JMeter from the link and extract it to a desired folder.Step 2 - Download and start WSO2 Message Broker
Download WSO2 Message Broker from the link and extract it to a desired folder. Then start the Message Broker by WSO2_MB_HOME/bin wso2server.sh or wso2server.bat file depending on the OS you are running on.
Step 3 - Add required client libraries
In order to use JMeter to pub / sub via WSO2 MB we need to add couple of jar files to JMeter. Go to WSO2_MB_HOME/client-libs and copy the below libraries to JMETER_HOME/lib folder.- andes-client-2.6.0.jar
- geronimo-jms_1.1_spec-1.1.0.wso2v1.jar
- slf4j-1.5.10.wso2v1.jar
- log4j-1.2.13.jar
- org.wso2.carbon.logging-4.4.1.jar
- org.wso2.securevault-1.0.0-wso2v2.jar
Step 4 - Create a JNDI
To use WSO2 MB you need to create a jndi.properties file in order to create the connection. Refer below image to create a sample jndi property file.
- Connection factory - give the user name and password ( admin is default user name and password ) and the IP of the broker.
- Give a queue name, in the example I have used the queue name is "QueOne"
jndi.properties |
Step 5 - Create a JMS Subscriber from JMeter to consume messages
Now start JMeter by navigating to JMETER_HOME/bin and run jmeter.sh / jmeter.bat depending on your OS.
To create a test plan first add a thread group and then right click on the thread group and from "Sampler" section add "JMS Subscriber".
Then fill the sampler as follows,
Then fill the sampler as follows,
- Initial Context Factory - org.wso2.andes.jndi.PropertiesFileInitialContextFactory
- Provider URL - /home/jasons/Softwares/Jmeter2/apache-jmeter-2.9/wso2mb/jndi.properties (Path to created jndi)
- Connection Factory - QueueConnectionFactory
- Destination - QueueOne
JMS Subscriber |
After creating the subscriber run the subscriber ones and stop the subscriber this will create the queue in the WSO2 message broker(Note that you can manually create a queue from the Message Broker management console too)
Step 6 - Create a JMS Publisher
To create a publisher you can do so by creating a thread group and then from "Sampler" section add "JMS Publisher" sampler.
- Initial Context Factory - org.wso2.andes.jndi.PropertiesFileInitialContextFactory
- Provider URL - /home/jasons/Softwares/Jmeter2/apache-jmeter-2.9/wso2mb/jndi.properties (Path to created jndi)
- Connection Factory - QueueConnectionFactory
- Destination - QueueOne
- Message - Provide a file or text message I have used a text messge for this example
JMS Publisher |
Step 7 - View published message stats in Message Broker
Login to Message Broker Management console by going to https://localhost:9443/carbon/ provide user name and password as admin. Then you can navigate to Queues section and view the published messages and queue details.
WSO2 Message Broker console |
Now run the Subscriber and the messages that was published will be consumed. You can view the details via JMeter buy adding a desired listener to examine the message status etc.
Hi Jason - this is not working for me. Can you please help?
ReplyDeletehttps://stackoverflow.com/questions/58089651/wso2-point-to-point-messaging