Bug 62256

Summary: JMS (P2P) and JMS Subscriber not working properly with Throughput Controller in a Test script
Product: JMeter Reporter: vishalendu
Component: MainAssignee: JMeter issues mailing list <issues>
Status: NEW ---    
Severity: normal    
Priority: P2    
Version: 4.0   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: JMeter script for the POC of issue

Description vishalendu 2018-04-04 13:15:10 UTC
Created attachment 35838 [details]
JMeter script for the POC of issue

I am doing an automation where 
1) A script (Producer) will call some API and put the output on a JMS Queue. It would end after that.
2) Another script (Consumer) will pick these messages and execute them.

I had some issue with the second script. (Which almost took a day to figure out.)
Script look something like this:

Read From JMS (JMS P2P) (Tried this with JMS Subscriber as well)
   If (Message not empty)
      Throughput Controller 1 (50%)
                : Do some work
      Throughput Controller 2 (50%)
                : Do some work


Even though, I was running the above script with a single thread and 2 iterations, I could see in the Result Tree Listener that the "JMS P2P" sampler was getting called 2 times in the begining, instead of being called sequentially. This was confusing and frustrating, since I was running 1 thread.

FYI, there is a configuration on the JMS P2P/JMS Subscriber samplers "Number of Samples to aggregate". This was set to 1 all along.

Since the JMS P2P was getting called in the beginning 2 times, both the Throughput Controllers were getting the last JMS message. Due to this, one of the Transaction passed and the other failed.

I had to resort to the following solution:

Read From JMS (JMS P2P)
   If (Message not empty)
       Random Controller1
               : Simple Controller1
                       : Do some work
       Random Controller2
               : Simple Controller2
                       : Do some work

I am attaching a script that I used to do a POC for this issue. You will have to add activemq jars to your lib/ext for the ActiveMQ JMS P2P to work. Create a test queue named TestQueue and put the following messages:

{"txnId":"1"}
and
{"txnId":"2"}

When you run the attached test script, the JSR223 Sampler1/2 will both print the txnId as 2. Even though there is only 1 thread and 2 iterations.