You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Babak Vahdat (JIRA)" <ji...@apache.org> on 2012/12/21 11:27:12 UTC

[jira] [Commented] (CAMEL-5900) StreamResequencer does not resequence correctly

    [ https://issues.apache.org/jira/browse/CAMEL-5900?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13537789#comment-13537789 ] 

Babak Vahdat commented on CAMEL-5900:
-------------------------------------

Regarding the test:

{code}
testSendMessagesInWrongOrderButReceiveThemInCorrectOrder()
{code}

When you define a timeout of 20 seconds inside the route (e.g. {{timeout(20000L)}}) then you would need to wait _at least_ for this amount of time by the MockEndpoint before asserting on it, like:

{code}
resultEndpoint.setResultWaitTime(25000L);
resultEndpoint.expectedBodiesReceived("msg1", "msg2", "msg3", "msg4");
...
{code}

And concerning the test:

{code}
testMultithreaded()
{code}

Well 9000 messages you have defined here is "a bit more" than just 100 messages. So you need to give it a bit of time for processing until it's done, on my box I set the result wait timeout to {{40 seconds}} by this test to make it pass:

{code}
...
resultEndpoint.expectedBodiesReceived(bodies);
resultEndpoint.setResultWaitTime(40000L);
resultEndpoint.assertIsSatisfied();
...
{code}

Also be aware of the {{4 ms}} the {{Sender}} sleeps before sending *each* exchange which for 9000 messages brings a bit of delay into the play as well.

Please better provide a concrete unit-test of yours showing the problem you're facing, then it's easier for us to follow the problem (and probably fix it if any).
Also a *much* better approach would be to _first_ ask for help @ the user forum as we already say this by the blue box below:

http://camel.apache.org/support.html

                
> StreamResequencer does not resequence correctly
> -----------------------------------------------
>
>                 Key: CAMEL-5900
>                 URL: https://issues.apache.org/jira/browse/CAMEL-5900
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.11.0
>         Environment: Windows XP dual-core, Sun JDK 1.6.x
> Ubuntu Linux quad-core, openjdk 6b24-1.11.5-0ubuntu1~12.04.1
> Ubuntu Linux quad-core, openjdk 7u9-2.3.3-0ubuntu1~12.04.1
> Camel 2.10 release version
> Camel 2.11 snapshot code, svn checkout on 2012-12-18.
>            Reporter: Vincent Lombart
>             Fix For: 2.11.0
>
>
> On some routes we noticed that the StreamResequencer was not resequencing correctly. By playing with the Camel unit test (org.apache.camel.processor.StreamResequencerTest) I was able to reproduce the problem.
> Test setup: 
> 1. In the createRouteBuilder() method change the capacity and timeout to avoid false problems. I used:
> from("direct:start").resequence(header("seqnum")).stream().capacity(10000).timeout(20000L).to("mock:result");
> 2. In the testMultithreaded() method change numMessages to a high number (I used 9000).
> 3. Run the unit test several times until it fails. It does not fail consistently which probably indicates a race condition / wrong synchronization. You might have to adapt the numbers above to have it fail on other configurations.
> The testSendMessagesInWrongOrderButReceiveThemInCorrectOrder() often fails with
> java.lang.AssertionError: mock://result Received message count. Expected: <4> but was: <0>
> 	at org.apache.camel.component.mock.MockEndpoint.fail(MockEndpoint.java:1318)
> 	at org.apache.camel.component.mock.MockEndpoint.assertEquals(MockEndpoint.java:1300)
> 	at org.apache.camel.component.mock.MockEndpoint.doAssertIsSatisfied(MockEndpoint.java:372)
> 	at org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:351)
> 	at org.apache.camel.component.mock.MockEndpoint.assertIsSatisfied(MockEndpoint.java:339)
> 	at org.apache.camel.processor.StreamResequencerTest.testSendMessagesInWrongOrderButReceiveThemInCorrectOrder(StreamResequencerTest.java:56)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.lang.reflect.Method.invoke(Method.java:601)
> 	at junit.framework.TestCase.runTest(TestCase.java:168)
> 	at junit.framework.TestCase.runBare(TestCase.java:134)
> 	at org.apache.camel.TestSupport.runBare(TestSupport.java:58)
> 	at junit.framework.TestResult$1.protect(TestResult.java:110)
> 	at junit.framework.TestResult.runProtected(TestResult.java:128)
> 	at junit.framework.TestResult.run(TestResult.java:113)
> 	at junit.framework.TestCase.run(TestCase.java:124)
> 	at junit.framework.TestSuite.runTest(TestSuite.java:243)
> 	at junit.framework.TestSuite.run(TestSuite.java:238)
> 	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
> 	at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
> 	at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
> 	at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
> I also often get the testMultithreaded() that fails with:
> Exception in thread "pool-2-thread-2" org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: msg5181]
> 	at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1287)
> 	at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:618)
> 	at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:454)
> 	at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:450)
> 	at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeader(DefaultProducerTemplate.java:152)
> 	at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeader(DefaultProducerTemplate.java:146)
> 	at org.apache.camel.processor.StreamResequencerTest$Sender.run(StreamResequencerTest.java:147)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> 	at java.lang.Thread.run(Thread.java:722)
> Caused by: org.apache.camel.CamelExchangeException: No consumers available on endpoint: Endpoint[direct://start]. Exchange[Message: msg5181]
> 	at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:56)
> 	at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
> 	at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
> 	at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63)
> 	at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:366)
> 	at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:1)
> 	at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:233)
> 	at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:337)
> 	at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:175)
> 	at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:111)
> 	at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeader(DefaultProducerTemplate.java:150)
> 	... 5 more
> Exception in thread "pool-2-thread-1" org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[Message: msg5184]
> 	at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1287)
> 	at org.apache.camel.util.ExchangeHelper.extractResultBody(ExchangeHelper.java:618)
> 	at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:454)
> 	at org.apache.camel.impl.DefaultProducerTemplate.extractResultBody(DefaultProducerTemplate.java:450)
> 	at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeader(DefaultProducerTemplate.java:152)
> 	at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeader(DefaultProducerTemplate.java:146)
> 	at org.apache.camel.processor.StreamResequencerTest$Sender.run(StreamResequencerTest.java:147)
> 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
> 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
> 	at java.lang.Thread.run(Thread.java:722)
> Caused by: org.apache.camel.CamelExchangeException: No consumers available on endpoint: Endpoint[direct://start]. Exchange[Message: msg5184]
> 	at org.apache.camel.component.direct.DirectProducer.process(DirectProducer.java:56)
> 	at org.apache.camel.processor.UnitOfWorkProcessor.processAsync(UnitOfWorkProcessor.java:150)
> 	at org.apache.camel.processor.UnitOfWorkProcessor.process(UnitOfWorkProcessor.java:117)
> 	at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:99)
> 	at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:86)
> 	at org.apache.camel.processor.UnitOfWorkProducer.process(UnitOfWorkProducer.java:63)
> 	at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:366)
> 	at org.apache.camel.impl.ProducerCache$2.doInProducer(ProducerCache.java:1)
> 	at org.apache.camel.impl.ProducerCache.doInProducer(ProducerCache.java:233)
> 	at org.apache.camel.impl.ProducerCache.sendExchange(ProducerCache.java:337)
> 	at org.apache.camel.impl.ProducerCache.send(ProducerCache.java:175)
> 	at org.apache.camel.impl.DefaultProducerTemplate.send(DefaultProducerTemplate.java:111)
> 	at org.apache.camel.impl.DefaultProducerTemplate.sendBodyAndHeader(DefaultProducerTemplate.java:150)
> 	... 5 more

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira