Bug 47949 - JMS Subscriber never recieves all the messages
JMS Subscriber never recieves all the messages
Status: RESOLVED FIXED
Product: JMeter
Classification: Unclassified
Component: Main
2.3.4
PC Windows Server 2003
: P2 critical (vote)
: ---
Assigned To: JMeter issues mailing list
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2009-10-06 08:24 UTC by Hiskill
Modified: 2010-05-01 21:27 UTC (History)
0 users



Attachments
Patch to ReceiveSubscriber.java (2.65 KB, patch)
2009-11-04 17:52 UTC, Bob Yetman
Details | Diff
Patch to SubscriberSampler.java (6.75 KB, patch)
2009-11-04 17:53 UTC, Bob Yetman
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hiskill 2009-10-06 08:24:58 UTC
I configured a simple JMS Topic with one Subscriber and one Publisher.  Subscriber sampler never seems to recieve all the messages published by the sampler.

For eg, when my jmeter test is configured to publish 10 messages and subscriber sampler recieving indefintely, the report shows as 10 messages published but subscriber shows only recieved as 4-9 messages recieved from various runs.

To make sure its a jmeter issue, I wrote simple subscriber code and ran the jmeter test, I recive all the 10 messages through my sample code where as jmeter subscriber recives only some of them.

This is a major blocker for us to do the load testing.

Is this a known bug, please let me know the workaround if any.
Comment 1 Bob Yetman 2009-11-03 05:49:18 UTC
I've seen something similar, where the JMS SubscriberSampler will take multiple messages and combine them into a single message, which will make the counts lower then what you expect.    It's due to the while (this.count(0) < loop) { Thread.sleep } loops in the sampleWithListener() and SampleWithReceive() methods.  If multiple messages come in during the Thread.sleep() time periods, they will be aggregated into a single buffer, and returned as a single message.  In my case, it's causing some XPath Assertions to fail.

I've debated re-writing these methods to use an array of buffers to received the messages, just haven't had the time yet to code and test it.
Comment 2 Sebb 2009-11-03 07:01:37 UTC
The code always increments the counter when it appends a message to the buffer, and this is done in a synch. block.

However, the code does not count (or store) empty messages; likewise it skips messages that are not instances of TextMessage.

So I don't see how the problems are occurring.
This assumes you are using JMeter 2.3.4.
Comment 3 Bob Yetman 2009-11-03 10:51:30 UTC
(In reply to comment #2)
> The code always increments the counter when it appends a message to the buffer,
> and this is done in a synch. block.
> However, the code does not count (or store) empty messages; likewise it skips
> messages that are not instances of TextMessage.
> So I don't see how the problems are occurring.
> This assumes you are using JMeter 2.3.4.

I am using JMeter 2.3.4.
The problem is if 2 messages come into onMessage() before the sleep() expires in sampleWithListener(), then onMessage() will put both messages into a single buffer, and then they're read off as a single message in the sampleWithListener().   I've seen this happen in my testing (it cost me quite a few hours trying to find this problem).

A similar sequence of events can happen with sampleWithReceive() and the code in ReceiveSubscriber.java.
Comment 4 Sebb 2009-11-03 11:51:58 UTC
(In reply to comment #3)
> The problem is if 2 messages come into onMessage() before the sleep() expires
> in sampleWithListener(), then onMessage() will put both messages into a single
> buffer, and then they're read off as a single message in the
> sampleWithListener().   I've seen this happen in my testing (it cost me quite a
> few hours trying to find this problem).
> 
> A similar sequence of events can happen with sampleWithReceive() and the code
> in ReceiveSubscriber.java.

Agreed, more messages can appear in the buffer than requested, and the count can be lower than the actual.

This has been fixed in SVN:

URL: http://svn.apache.org/viewvc?rev=832521&view=rev
Log:
Better handling of received count

The sample count will now agree with the buffer contents, but may there may be more messages than requested.
Comment 5 Bob Yetman 2009-11-03 12:01:58 UTC
Sebb;

I've got an alternate implementation that I put together today (had a few spare hours at work), that uses a Queue so messages are kept separate and allows you to read only the number of messages requested.   I've modified both the withRecieve() and withListener() scenarios, do you want me to post it here?

(In reply to comment #4)
> Agreed, more messages can appear in the buffer than requested, and the count
> can be lower than the actual.
> This has been fixed in SVN:
> URL: http://svn.apache.org/viewvc?rev=832521&view=rev
> Log:
> Better handling of received count
> The sample count will now agree with the buffer contents, but may there may be
> more messages than requested.
Comment 6 Sebb 2009-11-03 12:05:12 UTC
(In reply to comment #5)
> Sebb;
> 
> I've got an alternate implementation that I put together today (had a few spare
> hours at work), that uses a Queue so messages are kept separate and allows you
> to read only the number of messages requested.   I've modified both the
> withRecieve() and withListener() scenarios, do you want me to post it here?

Yes please, assuming that it will run on Java 1.5+.
Comment 7 Bob Yetman 2009-11-04 17:52:48 UTC
Created attachment 24484 [details]
Patch to ReceiveSubscriber.java
Comment 8 Bob Yetman 2009-11-04 17:53:18 UTC
Created attachment 24485 [details]
Patch to SubscriberSampler.java
Comment 9 Bob Yetman 2009-11-04 17:55:10 UTC
I've attached patches to both SubscriberSampler.java and ReceiveSubscriber.java to use a queue rather then a single buffer, which should allow for receipt of all messages, and the correct count.   Also in the patch is a couple of hacks to display the JMS message properties, which was something I needed to do at work.

They're working reasonably well for me, and have solved my merged message problem.
Comment 10 Sebb 2010-05-01 21:27:28 UTC
Thanks for the patches, which have been applied with one minor change: if the samplers are interrupted, then the queues can be empty, so the message handlers need to allow for null message response.


URL: http://svn.apache.org/viewvc?rev=940130&view=rev
Log:
Bug 47949 - JMS Subscriber may not receive all the messages

Modified:
   jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/client/ReceiveSubscriber.java
   jakarta/jmeter/trunk/src/protocol/jms/org/apache/jmeter/protocol/jms/sampler/SubscriberSampler.java
   jakarta/jmeter/trunk/xdocs/changes.xml