Sorry for the very broad question: Can some one please throw some light 
on how idempotent consumers actually work?

I would like to have my routes available in a cluster and hence I 
am exploring the use of Hazelcase idempotent repository. To prototype
that I experimented with two routes in one context in a single node.

Both the routes consume from the same topic and use the same 
hazelcast idempotent repository. When a message is received from 
the topic both the routes process the message. Given that they use 
the same repository how/why do both the routes process the message?

        context().addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {

                from("activemq:topic:test")
                        .routeId("one")
                        .setHeader("foo", constant("bar"))
                        .idempotentConsumer(header("foo"), repository)
                        .log("Received ${body} in one");
            }
        });

        context().addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                from("activemq:topic:test")
                        .routeId("two")
                        .setHeader("foo", constant("bar"))
                        .idempotentConsumer(header("foo"), repository)
                        .log("Received ${body} in two");
            }
        });

        template().sendBody("activemq:topic:test", 12345);
        template().sendBody("activemq:topic:test", 45678);
        template().sendBody("activemq:topic:test", 90123);

In the above case, both the routes receive only the first 
message (not really surprising given that the key is hard-coded) 
once. So it appears idempotency is scoped to the route. 

I would eventually like to have the routes deployed in a cluster with 
each message being handled by only one of the routes in the 
cluster (i.e. either route "one" in node 1 or route "one" in node 2). 
Given the above observation I am confused how the same route 
deployed in two nodes would not process the each message.

Thanks!



--
View this message in context: 
http://camel.465427.n5.nabble.com/Understanding-Idempotent-Consumption-tp5718481.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to