You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by yogu13 <yo...@gmail.com> on 2017/09/01 10:31:40 UTC

Adding Network connectors dynamically

Hello,

I have a question on setting up network of brokers dynamically i.e. not via
usual static configuration via XML. To explain my scenario we have a
discovery server which can tell how many broker instances are available
(running) within an environment, We use programmatic API for configuring
ActiveMQ Broker so configuring network of brokers using this information
should be fairly easy. However I am curious once ActiveMQ Broker is
configured and running and if we want to scale then can we add a new
ActiveMQ broker's network configuration to already started BrokerService ?

In ActiveMQ API what I mean is

BrokerService broker = new BrokerService();
  // some activemq configuration
  ...
  ...
broker.start()

broker.addNetworkConnector("static:(tcp://10.x.x.x:62001)").start(); // not
sure if this would work

I cannot use Multicast as its disabled and I wanted to avoid configuring all
possible network connectors up front.

Thank you!

Regards,
-Yogesh




--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: Adding Network connectors dynamically

Posted by yogu13 <yo...@gmail.com>.
Hello Tim,

Thank you for your reply ..

Yes my brokers are embedded and the process gets notified of new servers
which come up. Once i wrote the question i did try it out and could see via
jmx that the network connector started working and showed up. However i
still need to get it working perfectly the way i need it..

Now my other challenge is for client processes i understand the connection
url needs to have all the broker ip and ports mentioned upfront for
failover. Is there a way i can add more brokers once connectionfactory is
created and initialized ?

I see connectionFactory.setBrokerURL(String brokerURL) API which is
available and not sure any updates to brokerURL made gets reflected. Any
ideas?

Regards,
-Yogesh



--
Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805.html

Re: Adding Network connectors dynamically

Posted by Tim Bain <tb...@alumni.duke.edu>.
Actually, the other way you could do this (maybe it's what you're
suggesting and I didn't catch it) is to make all your brokers embedded, and
put each of them inside of a process that finds out about changes to the
list of brokers. Then I believe that your general approach might work.
("Might" because this isn't something that I've personally done or heard of
people doing; sorry I don't know for sure.)

Note that you may need to start the networkConnector in addition to
creating it and adding it; look at
http://grepcode.com/file/repo1.maven.org/maven2/org.apache.activemq/activemq-core/5.7.0/org/apache/activemq/broker/BrokerService.java#BrokerService.startAllConnectors%28%29
for some ideas of things that you might need to do. Also, you should be
able to test whether it's possible to add a networkConnector at runtime by
modifying one of the JUnit tests in our codebase to match what you have in
mind. That would let you quickly figure out whether it's feasible without
sinking too much time into it.

Tim

On Sep 1, 2017 10:52 PM, "Tim Bain" <tb...@alumni.duke.edu> wrote:

> The code you're envisioning could only work if run within the broker
> process; to the best of my knowledge, you can't do what you're describing
> from a client process. That begs the question of how you'd give your code
> control to be able to run in the first place; maybe a custom broker plugin
> that listens for socket connections to tell it about changes to the list of
> brokers, or that watches a file listing all the brokers for changes?
>
> It's probably possible, but it's likely to require you to spend some
> quality time with the ActiveMQ code. If that's not appealing, you could
> consider other options such as using a hub-and-spoke topology with duplex
> networkConnectors from the spoke to the hub, so that no broker needs to
> know about any broker other than the hub.
>
> Tim
>
> On Sep 1, 2017 8:44 AM, "yogu13" <yo...@gmail.com> wrote:
>
>> Hello,
>>
>> I have a question on setting up network of brokers dynamically i.e. not
>> via
>> usual static configuration via XML. To explain my scenario we have a
>> discovery server which can tell how many broker instances are available
>> (running) within an environment, We use programmatic API for configuring
>> ActiveMQ Broker so configuring network of brokers using this information
>> should be fairly easy. However I am curious once ActiveMQ Broker is
>> configured and running and if we want to scale then can we add a new
>> ActiveMQ broker's network configuration to already started BrokerService ?
>>
>> In ActiveMQ API what I mean is
>>
>> BrokerService broker = new BrokerService();
>>   // some activemq configuration
>>   ...
>>   ...
>> broker.start()
>>
>> broker.addNetworkConnector("static:(tcp://10.x.x.x:62001)").start(); //
>> not
>> sure if this would work
>>
>> I cannot use Multicast as its disabled and I wanted to avoid configuring
>> all
>> possible network connectors up front.
>>
>> Thank you!
>>
>> Regards,
>> -Yogesh
>>
>>
>>
>>
>> --
>> Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-f2341805
>> .html
>>
>

Re: Adding Network connectors dynamically

Posted by Tim Bain <tb...@alumni.duke.edu>.
The code you're envisioning could only work if run within the broker
process; to the best of my knowledge, you can't do what you're describing
from a client process. That begs the question of how you'd give your code
control to be able to run in the first place; maybe a custom broker plugin
that listens for socket connections to tell it about changes to the list of
brokers, or that watches a file listing all the brokers for changes?

It's probably possible, but it's likely to require you to spend some
quality time with the ActiveMQ code. If that's not appealing, you could
consider other options such as using a hub-and-spoke topology with duplex
networkConnectors from the spoke to the hub, so that no broker needs to
know about any broker other than the hub.

Tim

On Sep 1, 2017 8:44 AM, "yogu13" <yo...@gmail.com> wrote:

> Hello,
>
> I have a question on setting up network of brokers dynamically i.e. not via
> usual static configuration via XML. To explain my scenario we have a
> discovery server which can tell how many broker instances are available
> (running) within an environment, We use programmatic API for configuring
> ActiveMQ Broker so configuring network of brokers using this information
> should be fairly easy. However I am curious once ActiveMQ Broker is
> configured and running and if we want to scale then can we add a new
> ActiveMQ broker's network configuration to already started BrokerService ?
>
> In ActiveMQ API what I mean is
>
> BrokerService broker = new BrokerService();
>   // some activemq configuration
>   ...
>   ...
> broker.start()
>
> broker.addNetworkConnector("static:(tcp://10.x.x.x:62001)").start(); //
> not
> sure if this would work
>
> I cannot use Multicast as its disabled and I wanted to avoid configuring
> all
> possible network connectors up front.
>
> Thank you!
>
> Regards,
> -Yogesh
>
>
>
>
> --
> Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-
> f2341805.html
>