Jmeter & Rabbit MQ
Rabbit MQ is a open source message broker which uses the AMQP protocol. Jmeter has a number of methods to inject messages on to Rabbit MQ queues. In this example we are using the AMQP client.
PRE-REQUISITE
You will need an instance of RabbitMQ to be installed, configured and running to follow this tutorial. The example values will not work unless you configure your RabbitMQ with those specific settings. This would mean that it would be installed on the same machine as Apache jmeter.
INSTALLATION
To use AMQP client within Apache Jmeter you will need to download two JARs the amqp client and the JMeter AMQP jar. In this blog we use older versions of the amqp client which are known to work with Rabbit MQ and JMeter. Later versions of the AMQP Client can be download from rabbitmq.com.
DOWNLOAD
To follow this blog you will need to download the files from the links below :-
AMQP Client jar - /<jmeter directory>/lib/amqp-client-3.0.3.jar
JMeter AMQP jar - /<jmeter directory>/lib/ext/JMeterAMQP.jar
INSTALLATION
Copy the downloaded file to the directories below:-
Copy amqp-client-3.0.3.jar to /<jmeter directory>/lib
Copy JMeterAMQP.jar to /<jmeter directory>/lib/ext
USAGE
Once the aforementioned files have been downloaded ensure that they have been copied to the relevant directories under your jmeter installation.
There are two samplers which are installed for the AMQP protocol. The AMQP Consumer and the AMQP Publisher. The AMQP Consumer reads messages from Rabbit MQ queues and the AMQP Publisher sends messages to Rabbit MQ queues.
CONSUME
To consume from queues you need to provide the host, port, username, password, exchange name or queue and routing key. If you queue has other specific requirements you will need to also supply them via the AMQP Consumer sampler.
Example values
Host = localhost
Port = 5672
Username = guest
Password = guest
Exchange = jmeterExchange
Queue = jmeterQueue
Routing Key = jmeterRoutingKey
PUBLISH
To publish to queues you need to provide the host, port, username, password, exchange name or queue, routing key and message content. If you queue has other specific requirements you will need to also supply them via the AMQP Consumer sampler.
Example values
Host = localhost
Port = 5672
Username = guest
Password = guest
Exchange = jmeterExchange
Queue = jmeterQueue
Routing Key = jmeterRoutingKey
Message Content = "I’m a message in a queue”
All other aspects of Jmeter can be used to control the test plan such as constant throughput timer. Since messages are typically small you should be able to consume and publish thousands of messages a second from a single JMeter instance.