Checking ActiveMQ queue is empty from JMeter

2019-07-31 14:41发布

问题:

I am running a performance test using JMeter for our application and the there is some asynchronous processing in the form of events on an ActiveMQ queue. I want to wait for the ActiveMQ queue to be empty before recording the statistics for my test. Is there a good way to do that?

I have explored the JMS Producer/Consumers in JMeter 2.10 but they consume messages off the queue which is not what I want as it modifies the original flow of the application. Is there a way to monitor the draining of the queue without consuming the messages of ActiveMQ?

I am using ActiveMQ 5.8 and JMeter 2.10

回答1:

You can get the pending messages in that queue using the MBean "org.apache.activemq:BrokerName=host1,Type=Queue,Destination=dest1" attribute: "QueueSize"

After checking once every few seconds and the value being not more than zero, you can start recording the statistics.



回答2:

I was able to monitor ActiveMQ using the HTTP Request to poll the ActiveMQ web console and get the state of all the queues in XML format. After that I used XPATH to extract the size of the queue I was interested in. The snapshots below show the configuration which I was finally able to use. The XPATH expression which I used was

/queues/queue[@name='${queueName}']/stats/@size

One additional thing which I has to do was to setup basic HTTP authentication to be able to connect to the ActiveMQ web console.

The MBean solution by Mahesh should also work if JMX is enabled on the server but it is not enabled by default.

I have documented it in detail here



回答3:

You can create a simple Java class that consumes all messages from the queue. JMeter can run it before tests.