activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dejan Bosanac <de...@nighttale.net>
Subject Re: Connectinfg a Broker to Multiple Brokers
Date Tue, 06 Oct 2009 10:59:33 GMT
Hi,

try something like this

        BrokerService brokerService= new BrokerService();
        brokerService.setBrokerName("broker1");
        brokerService.setPersistent(false);
        brokerService.setUseShutdownHook(false);
        brokerService.addConnector("tcp://localhost:61618");

        NetworkConnector connector1;
        connector1 = new DiscoveryNetworkConnector(new
URI("static:(tcp://localhost:61616)"));
        connector1.setName("C1");
        connector1.setDuplex(true);
        connector1.setNetworkTTL(2);
        brokerService.addNetworkConnector(connector1);

        NetworkConnector connector2 = new DiscoveryNetworkConnector(new
URI("static:(tcp://localhost:61617)"));
        connector2.setName("C2");
        connector2.setDuplex(true);
        connector2.setNetworkTTL(2);
        brokerService.addNetworkConnector(connector2);

        brokerService.start();

Cheers
--
Dejan Bosanac - http://twitter.com/dejanb

Open Source Integration - http://fusesource.com/
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Tue, Oct 6, 2009 at 1:44 AM, vivekarora <gangnath@yahoo.co.in> wrote:

>
> Hello,
> I am trying to develop a network of Brokers in which one broker is
> connected
> to two other brokers. I am using NetworkConnector to connect. I am using
> the
> following code :-
>
> BrokerService brokerService=null;
> brokerService.setBrokerName("broker1");
> brokerService.setPersistent(false);
> brokerService.setUseShutdownHook(false);
> brokerService.addConnector("tcp://" + brokerHost + ":" + brokerPort);
>
> NetworkConnector connector1;
> connector1 =
> brokerService.addNetworkConnector("static://"+"tcp://localhost:" +61612);
> connector1.setName("C1");
> connector1.setDuplex(true);
> connector1.setNetworkTTL(2);
>
> connector1 =
> brokerService.addNetworkConnector("static://"+"tcp://localhost:" +61613);
> connector1.setName("C2");
> connector1.setDuplex(true);
> connector1.setNetworkTTL(2);
>
> brokerService.start();
>
>
> When I try to connect the same broker to the second port 61613, it gives me
> an exception javax.management.InstanceAlreadyExistsException
>
> What am i doing wrong. Can i use the same NetworkConnector object to
> connect
> a broker with two other brokers.
> Please reply....?
>
> --
> View this message in context:
> http://www.nabble.com/Connectinfg-a-Broker-to-Multiple-Brokers-tp25757201p25757201.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message