camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian Feaver (JIRA)" <j...@apache.org>
Subject [jira] Created: (CAMEL-3188) Concurrent consumers on seda endpoint can cause content routing to mismatch
Date Fri, 01 Oct 2010 20:21:40 GMT
Concurrent consumers on seda endpoint can cause content routing to mismatch
---------------------------------------------------------------------------

                 Key: CAMEL-3188
                 URL: https://issues.apache.org/activemq/browse/CAMEL-3188
             Project: Apache Camel
          Issue Type: Bug
          Components: camel-core
    Affects Versions: 2.4.0
         Environment: Mac OS X 10.6.4
Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
            Reporter: Brian Feaver


When consuming concurrently from a seda endpoint, when the route contains a content router
based on the header, it will randomly route through the wrong choice.

In my specific case, I was consuming from an activemq queue, which would receive messages
with a header that would then determine which route it would follow. It would randomly send
messages down the wrong path. When I turned on tracing, it would behave itself. It also behaved
itself when I limited it to only a single consumer. I was, however, able to duplicate it with
the unit test below. Due to the concurrency issue, the test can occasionally pass, but run
it a couple times and it should fail. It'll either receive 2 messages when it should have
only gotten 1, or it will get no messages when it should have gotten 1.

{code:title=ConcurrencyTest.java|borderStyle=solid}
import org.apache.camel.EndpointInject;
import org.apache.camel.Produce;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.test.CamelTestSupport;

public class ConcurrencyTest extends CamelTestSupport {

	@EndpointInject(uri = "mock:result")
	protected MockEndpoint resultEndpoint;
	
	@EndpointInject(uri = "mock:otherResult")
	protected MockEndpoint otherResultEndpoint;

	@Produce(uri = "seda:start")
	protected ProducerTemplate template;

	public void testSendMatchingMessage() throws Exception {
		String expectedBody = "<matched/>";
		
		resultEndpoint.expectedBodiesReceived(expectedBody);
		otherResultEndpoint.expectedBodiesReceived(expectedBody);

		template.sendBodyAndHeader(expectedBody, "myDirection", "send");
		template.sendBodyAndHeader(expectedBody, "myDirection", "received");

		resultEndpoint.assertIsSatisfied();
	}

	@Override
    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
            public void configure() {
                from("seda:start?concurrentConsumers=10")
//                from("seda:start?concurrentConsumers=1")
                	.choice()
                		.when(header("myDirection").isEqualTo("send")).to("mock:result")
                		.when(header("myDirection").isEqualTo("received")).to("mock:otherResult");
            }
        };
    }
}
{code}

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


Mime
View raw message