[ 
https://issues.apache.org/activemq/browse/SM-628?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Oleg Zhurakousky resolved SM-628.
---------------------------------

    Resolution: Fixed

I was able to replicate inconsistencies of this and other similar tests and 
figure out why they were so unstable. 
Even though in the async message world we have to do something to give messages 
enough time to arrive It is hard to rely on Thread.sleep(...).  Some of us have 
better hardware then others, thus making it difficult to know the optimum time 
needed for messages to arrive. 
Here is what I did to make sure that I am right
Firs I ran this test several times with different Thread.sleep(..) values and 
start noticing that 9 out of 10 times it will run just fine, but then it would 
fail the test (mostly in the Cluster portion of the test) failing on this line:

assertFalse(receiver.getMessageList().hasReceivedMessage());

That was interesting because we are flushing all the messages before each 
message batch send. I was even able to verify with few debug statements that 
receivers are empty. I start suspecting that messages were still arriving after 
flush was executed. To verify it I had to modify the message content to include 
some type of unique identifier. When I did (simple static counter such as 1, 2, 
3, 4 . . . etc.), everything became clear. 
First test in the cluster test sends a batch of 10 messages with identifier 1, 
then flush, then second batch with identifier 2 and so on. Well, very quickly I 
start seeing that occasionally after sending second batch with identifier 2, I 
would still get a message on the receiver with identifier 1.
So, that is pretty much the story, if you guys need more details, just let me 
know.

The good news is that there are several tests that are very similar 
(JCAFlowTest, MultimpleJMSFlowTest etc.) which have the same problem and 
obviously the same fix.
I am recommending the attached two patches.
One is a new class (ClusterFlowTestHelper) that should be a base class for all 
the tests similar to JMSFlow test and obviously JMSFlowTest patch which removes 
all the Thread.sleep(), extends ClusterFlowTestHelper and calls its helper 
methods to verify that messages were received. Currently I am setting the 
timeout to 4000 msc even though on my machine all 10 messages arrive in under 
200 msc. I've also added another assert, so if after all messages do not arrive 
in the allotted time, then the test will fail (but at least we'll know exactly 
why).

If you agree with the proposed solution, I'll take care of all other tests in 
the similar way.


> org.apache.servicemix.jbi.nmr.flow.jms.JMSFlowTest
> --------------------------------------------------
>
>                 Key: SM-628
>                 URL: https://issues.apache.org/activemq/browse/SM-628
>             Project: ServiceMix
>          Issue Type: Sub-task
>          Components: servicemix-core
>    Affects Versions: 3.0
>            Reporter: Fritz Oconer
>             Fix For: 3.2
>
>         Attachments: SMTestCasesPatches.zip
>
>


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to