@Tarjei,

looking deeper at [1] just realized that there's a multipleConsumers option
you could use to consume multiple times from the same Seda endpoint (didn't
know that), see [2] which is implemented by the Seda endpoint.
I modified [3] to achieve what you expect, see [4] which I hope will be
helpful in your use-case.

[1] http://camel.apache.org/seda
[2]
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/main/java/org/apache/camel/MultipleConsumersSupport.java
[3]
https://svn.apache.org/repos/asf/camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaConcurrentConsumersTest.java
[4] public class SedaConcurrentConsumersTest extends ContextTestSupport {

    public void testSendToSeda() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        // only one consumer is running as the route "noAutoStartup" is
noAutoStartup() enabled
        mock.expectedBodiesReceived("Hello World");
        
        template.sendBody("seda:foo?multipleConsumers=true", "Hello World");
        assertMockEndpointsSatisfied();

        // reset the mock state so that the recieved body is purged
        mock.reset();

        context.getRoute("noAutoStartup").getConsumer().start();

        // now we would consume twice as the route "noAutoStartup" is now
running as well
        mock.expectedBodiesReceived("Second Hello World", "Second Hello
World");
        
        template.sendBody("seda:foo?multipleConsumers=true", "Second Hello
World");
        assertMockEndpointsSatisfied();
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            @Override
            public void configure() throws Exception {
               
from("seda:foo?multipleConsumers=true").routeId("noAutoStartup").noAutoStartup().to("mock:result");
               
from("seda:foo?multipleConsumers=true").routeId("autoStartup").to("mock:result");
            }
        };
    }
}


--
View this message in context: 
http://camel.465427.n5.nabble.com/NPE-when-using-SEDA-queue-tp4973626p4992840.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to