You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Jason Whaley <ja...@gmail.com> on 2011/08/08 14:10:55 UTC
AMQ PooledConnectionFactory configured in Java always going to localhost:61616
It's quite possible I'm being dense here, but when I am setting up a PooledConnectionFactory in java code for the camel ActiveMQ component, the component is instead creating connections for a broker at "tcp://localhost:61616" irrespective of what I have passed in to setBrokerURL. For instance, the following code
PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory();
pooledConnectionFactory.setMaxConnections(8);
pooledConnectionFactory.setMaximumActive(500);
ActiveMQComponent activeMQComponent = ActiveMQComponent.activeMQComponent("tcp://localhost:61618");
activeMQComponent.setUsePooledConnection(true);
activeMQComponent.setConnectionFactory(pooledConnectionFactory);
camelContext.addComponent("amq", activeMQComponent);
results in this output in the logs:
1916 [ActiveMQ Task-1] INFO org.apache.activemq.transport.failover.FailoverTransport - Successfully connected to tcp://localhost:61616
Note the port mismatch. I confirmed it is indeed working with a broker on localhost at port 61616 whenever I setup a route that includes a to("amq:queue:SomeQueue"). The same behavior occurs when I change the hostname/ip as well - it still connects to localhost:61616.
Then once I comment out related to using pooling and keep only the following two lines:
ActiveMQComponent activeMQComponent = ActiveMQComponent.activeMQComponent("tcp://localhost:61618");
camelContext.addComponent("amq", activeMQComponent);
Then this works as expected and the camel routes are working against the broker I have listening on port 61618.
Am I missing something obvious with using PooledConnectionFactory, is this is a PEBCAK, or is there really something wrong with setting up pooled connections in the activemq component this way?
Re: AMQ PooledConnectionFactory configured in Java always going to
localhost:61616
Posted by Ashwin Karpe <ak...@fusesource.com>.
Hi,
You should do the following
ActiveMQConfiguration config = new ActiveMQConfiguration();
config.setBrokerURL("tcp:....");
// Use Spring JmxTemplate to create and control a pooled
ConnectionFactory
config.setUsePooledConnection(true);
config.createPooledConnectionFactory(new
ActiveMQConnectionFactory("tcp:...");
// The commented line below creates a static component object..
// ActiveMQComponent activeMQComponent =
ActiveMQComponent.activeMQComponent("tcp://localhost:61618");
// You might want to use something like
ActiveMQComponent activeMQComponent = ActiveMQComponent(config);
camelContext.addComponent("amq", activeMQComponent);
This should do the trick...
Cheers,
Ashwin...
-----
---------------------------------------------------------
Ashwin Karpe
Apache Camel Committer & Sr Principal Consultant
FUSESource (a Progress Software Corporation subsidiary)
http://fusesource.com
Blog: http://opensourceknowledge.blogspot.com
---------------------------------------------------------
--
View this message in context: http://camel.465427.n5.nabble.com/AMQ-PooledConnectionFactory-configured-in-Java-always-going-to-localhost-61616-tp4677516p4678261.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: AMQ PooledConnectionFactory configured in Java always going to localhost:61616
Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Aug 8, 2011 at 4:32 PM, Tim <ch...@gmail.com> wrote:
> You have to set the brokerURL on the PooledConnectionFactory.
>
Regardless what I think ActiveMQ should report some kind of exception
stating the configuration is wrong. Jason I think you should create a
JIRA ticket in ActiveMQ. You are welcome to look into this and provide
a patch if you can.
> On Mon, Aug 8, 2011 at 7:10 AM, Jason Whaley <ja...@gmail.com> wrote:
>> It's quite possible I'm being dense here, but when I am setting up a PooledConnectionFactory in java code for the camel ActiveMQ component, the component is instead creating connections for a broker at "tcp://localhost:61616" irrespective of what I have passed in to setBrokerURL. For instance, the following code
>>
>> PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory();
>> pooledConnectionFactory.setMaxConnections(8);
>> pooledConnectionFactory.setMaximumActive(500);
>>
>> ActiveMQComponent activeMQComponent = ActiveMQComponent.activeMQComponent("tcp://localhost:61618");
>> activeMQComponent.setUsePooledConnection(true);
>> activeMQComponent.setConnectionFactory(pooledConnectionFactory);
>> camelContext.addComponent("amq", activeMQComponent);
>>
>> results in this output in the logs:
>>
>> 1916 [ActiveMQ Task-1] INFO org.apache.activemq.transport.failover.FailoverTransport - Successfully connected to tcp://localhost:61616
>>
>> Note the port mismatch. I confirmed it is indeed working with a broker on localhost at port 61616 whenever I setup a route that includes a to("amq:queue:SomeQueue"). The same behavior occurs when I change the hostname/ip as well - it still connects to localhost:61616.
>>
>> Then once I comment out related to using pooling and keep only the following two lines:
>>
>> ActiveMQComponent activeMQComponent = ActiveMQComponent.activeMQComponent("tcp://localhost:61618");
>> camelContext.addComponent("amq", activeMQComponent);
>>
>> Then this works as expected and the camel routes are working against the broker I have listening on port 61618.
>>
>> Am I missing something obvious with using PooledConnectionFactory, is this is a PEBCAK, or is there really something wrong with setting up pooled connections in the activemq component this way?
>>
>>
>>
>
--
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/
Re: AMQ PooledConnectionFactory configured in Java always going to localhost:61616
Posted by Tim <ch...@gmail.com>.
You have to set the brokerURL on the PooledConnectionFactory.
On Mon, Aug 8, 2011 at 7:10 AM, Jason Whaley <ja...@gmail.com> wrote:
> It's quite possible I'm being dense here, but when I am setting up a PooledConnectionFactory in java code for the camel ActiveMQ component, the component is instead creating connections for a broker at "tcp://localhost:61616" irrespective of what I have passed in to setBrokerURL. For instance, the following code
>
> PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory();
> pooledConnectionFactory.setMaxConnections(8);
> pooledConnectionFactory.setMaximumActive(500);
>
> ActiveMQComponent activeMQComponent = ActiveMQComponent.activeMQComponent("tcp://localhost:61618");
> activeMQComponent.setUsePooledConnection(true);
> activeMQComponent.setConnectionFactory(pooledConnectionFactory);
> camelContext.addComponent("amq", activeMQComponent);
>
> results in this output in the logs:
>
> 1916 [ActiveMQ Task-1] INFO org.apache.activemq.transport.failover.FailoverTransport - Successfully connected to tcp://localhost:61616
>
> Note the port mismatch. I confirmed it is indeed working with a broker on localhost at port 61616 whenever I setup a route that includes a to("amq:queue:SomeQueue"). The same behavior occurs when I change the hostname/ip as well - it still connects to localhost:61616.
>
> Then once I comment out related to using pooling and keep only the following two lines:
>
> ActiveMQComponent activeMQComponent = ActiveMQComponent.activeMQComponent("tcp://localhost:61618");
> camelContext.addComponent("amq", activeMQComponent);
>
> Then this works as expected and the camel routes are working against the broker I have listening on port 61618.
>
> Am I missing something obvious with using PooledConnectionFactory, is this is a PEBCAK, or is there really something wrong with setting up pooled connections in the activemq component this way?
>
>
>