You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by jessezbj <je...@hotmail.com> on 2011/09/15 04:35:03 UTC

How to create connections to different brokers by using one ConnectionFactory?

How to create connections to different brokers by using one
ConnectionFactory?

Can the code be written as

ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory();

for each url in URLs {
connectionFactory.setBrokerURL(url);
Connection connection = connectionFactory.createConnection();
connection.start();
}

And is there any other  better way to manage multiple connections (to
different brokers) in one client (which can save resources on the client,
save the scheduling overhead, and so on.

Thanks...

--
View this message in context: http://activemq.2283324.n4.nabble.com/How-to-create-connections-to-different-brokers-by-using-one-ConnectionFactory-tp3814559p3814559.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: How to create connections to different brokers by using one ConnectionFactory?

Posted by Marcelo Jabali <mj...@fusesource.com>.
I haven't used myself but maybe the Fanout Transport could help you here. Take a look on http://activemq.apache.org/fanout-transport-reference.html to see if that helps.

Thanks,

-Marcelo

On Sep 14, 2011, at 8:09 PM, Jason Whaley wrote:

> With a single connection factory you can only use the failover transport ( http://activemq.apache.org/failover-transport-reference.html ) to connect to multiple brokers, but only one broker URL will be used at a time.  
> 
> If you want to have two active connections (or connection pools) to two different brokers simultaneously you need to have multiple connection factories.  
> 
> On Sep 14, 2011, at 7:35 PM, jessezbj wrote:
> 
>> How to create connections to different brokers by using one
>> ConnectionFactory?
>> 
>> Can the code be written as
>> 
>> ActiveMQConnectionFactory connectionFactory = new
>> ActiveMQConnectionFactory();
>> 
>> for each url in URLs {
>> connectionFactory.setBrokerURL(url);
>> Connection connection = connectionFactory.createConnection();
>> connection.start();
>> }
>> 
>> And is there any other  better way to manage multiple connections (to
>> different brokers) in one client (which can save resources on the client,
>> save the scheduling overhead, and so on.
>> 
>> Thanks...
>> 
>> --
>> View this message in context: http://activemq.2283324.n4.nabble.com/How-to-create-connections-to-different-brokers-by-using-one-ConnectionFactory-tp3814559p3814559.html
>> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
> 







Re: How to create connections to different brokers by using one ConnectionFactory?

Posted by Jason Whaley <ja...@gmail.com>.
With a single connection factory you can only use the failover transport ( http://activemq.apache.org/failover-transport-reference.html ) to connect to multiple brokers, but only one broker URL will be used at a time.  

If you want to have two active connections (or connection pools) to two different brokers simultaneously you need to have multiple connection factories.  

On Sep 14, 2011, at 7:35 PM, jessezbj wrote:

> How to create connections to different brokers by using one
> ConnectionFactory?
> 
> Can the code be written as
> 
> ActiveMQConnectionFactory connectionFactory = new
> ActiveMQConnectionFactory();
> 
> for each url in URLs {
> connectionFactory.setBrokerURL(url);
> Connection connection = connectionFactory.createConnection();
> connection.start();
> }
> 
> And is there any other  better way to manage multiple connections (to
> different brokers) in one client (which can save resources on the client,
> save the scheduling overhead, and so on.
> 
> Thanks...
> 
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/How-to-create-connections-to-different-brokers-by-using-one-ConnectionFactory-tp3814559p3814559.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.