In this post, I will cover how to publish a Text Message and a Map Message using Apache Jmeter to queues and topics registered in WSO2 Message Broker.
I am using,
- Apache Jmeter 2.13
- WSO2 Message Broker 2.2.0
Adding required client libraries
By default Jmeter does not include any JMS implementation jars in its distribution. This must be downloaded from the JMS provider and put in the lib directory of Jmeter.If you are using WSO2 Message Broker, the required libraries can be found at MB_HOME/client-lib directory. Then, copy the following jars into the JMETER_HOME/lib directory.
- andes-client-2.6.1.jar
- geronimo-jms_1.1_spec-1.1.0.wso2v1.jar
- org.wso2.securevault-1.0.0-wso2v2.jar
Configuring JMS Subscriber in Jmeter
First of all, lets create a new test plan with a suitable name. I have created the test plan as "Message Broker Subscribers".Next, right click on "Message Broker Subscribers" and go to Add -> Threads -> Thread Group and add a thread group.
Then, right click on Thread Group -> Add -> Sampler and add a JMS Subscriber.
Now, lets configure the properties of the JMS Subscriber request.
Initial Context Factory: The standard initial context factory for WSO2 message broker.
value: org.wso2.andes.jndi.PropertiesFileInitialContextFactory
Provider URL:
Instead of directly giving the provider URL, we give the full path to a jndi.properties file, where we add all the required configurations in one file.
A sample jndi.properties file is provided below.
# register some connection factories # connectionfactory.[jndiname] = [ConnectionURL] connectionfactory.QueueConnectionfactory=amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5672' connectionfactory.TopicConnectionFactory=amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5672' # register some queues in JNDI using the form # queue.[jndiName] = [physicalName] queue.MyQueue = MyQueue # register some topics in JNDI using the form # topic.[jndiName] = [physicalName] #topic.MyTopic = MyTopic
Connection Factory:
JNDI connection factory defined in the jndi.properties file. This is configured as
connectionfactory.QueueConnectionfactory = amqp://admin:admin@clientID/carbon?brokerlist='tcp://localhost:5672' in jndi.properties file.
Destination:
The queue or topic that we are going to publish and subscribe messages. This is also configured in the jndi.properties file as queue.myQueue = MyQueue
Configuring JMS Publisher in Jmeter
Now, lets configure publishers who can send different types of JMS messages to a queue or topic.Create a new test plan. I will name it as "Message Broker Publishers".
Next, right click on "Message Broker Publishers" and go to Add -> Threads -> Thread Group and add a thread group.
Then, right click on Thread Group -> Add -> Sampler and add a JMS Publisher.
Configure the JMS Publisher request as explained above for the JMS Subscriber.
Configurations for sending specific message types are explained below.
Configuring a TextMessage
Right below the JMS Properties table you can find the properties to configure to send a text message.Message Source - Text area
Message Type - Text Message
Add the text message you want to send in the text area.
Configuring a MapMessage
Add a new JMS publisher to the same thread group and give it a meaningful name. Do the basic configurations as described above.Then, do the configurations as below to send a map message.
Message Source - Text area
Message Type - Map Message
Add the map message in the text area. Jmeter reads a map message source as lines of text. There are 3 fields that should be configured delimited by commas.
- Name of entry (the key/name) - should be a String
- Object class name - Any primitive type in Java language
- Value
For each entry, Jmeter adds an Object with the given name. The value is derived by creating an instance of the class.
Now, we are ready to run the test plan.
If you are using WSO2 Message Broker, when you start the test plan "Message Broker Subscribers", the queue/topic will be created in Message Broker and subscribers will be subscribed and listening to the queue/topic.
Then, when you start the "Message Broker Publishers" test plan, messages will be published to the queue/topic and subsequently received by the subscribers.
No comments:
Post a Comment