Hi, 

I have a simple problem, but I can't figure out how to solve it.

I have the following piece of code (as an example) where I am using Qpid
AMQP broker and configuring 2 endpoints from 2 topics to route to the same
end point. 

public class TestApp {

    public static void main(String[] args) throws Exception {

        CamelContext context = new DefaultCamelContext();
        
        new AMQAnyDestination("ADDR:queue_one; {create: always}");
        new AMQAnyDestination("ADDR:queue_two; {create: always}");

        final Component component =
AMQPComponent.amqpComponent("amqp://guest:guest@clientid/development?brokerlist='tcp://localhost:5672'");
        context.addComponent("abc", component);

        context.addRoutes(new RouteBuilder() {
            public void configure() {
                from("abc:topic:queue_one").to("direct:otherep");
                from("abc:topic:queue_two").to("direct:otherep");
            }
        });
        
        context.start();
        Thread.sleep(10000);
        context.stop();
    }
}

I expect that only one connection to the broker will be created and that all
messages that I receive on my 2 topics will route to the same
"direct:otherep" endpoint.

In practice however the behaviour is different. 2 connections are created to
the broker as seen from the following log extract:

2012-06-28 19:03:31,264 [INFO-main] qpid.client.AMQConnection -
Connection:amqp://guest:********@clientid/development?brokerlist='tcp://localhost:5672'
2012-06-28 19:03:32,168 [DEBUG-main] qpid.client.AMQConnection - Are we
connected:true
2012-06-28 19:03:32,174 [INFO-main] qpid.client.AMQConnection -
Connection:amqp://guest:********@clientid/development?brokerlist='tcp://localhost:5672'
2012-06-28 19:03:32,168 [DEBUG-main] qpid.client.AMQConnection - Are we
connected:true

Why is it that this creates 2 connections? I know it's something to do with
the way my routes are configured, but I can't figure out why.

Thanks!

--
View this message in context: 
http://camel.465427.n5.nabble.com/Question-Why-are-2-connections-created-tp5715235.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to