On Tue, Mar 24, 2009 at 2:58 PM, ronchalant <ronchal...@gmail.com> wrote: > > I want to embed an ActiveMQ broker into an application so that when the > application starts, the broker starts. This broker would be part of a chain > of brokers in a store-forward architecture*, and these brokers may go > up/down. What I need to be able to do is that as brokers are added or > removed from a system, other brokers recognize this. All consumers would be > local; this is intended to be used to distribute tasks among different > instances of the application. > > Are there samples anywhere of this sort of thing, starting the ActiveMQ > Brokers dynamically within code, and tearing them down within code as well? > Ideally, in a controlled teardown, I'd like to forward all messages to other > brokers if any are available manually (though this isn't critical, because > if the node comes back up it should just pick those messages up under > store-forward, correct?)
There are JUnit tests throughout the code base that demonstrate how to do this. Here's some info on some ways to embed a broker: http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html > I apologize if I'm missing the examples somewhere on the site, all I'm > seeing is various ways to start/stop brokers, producers and consumers from > the command line. > > *tentatively; a master/slave w/ KahaDB might be preferable if it was stable Master/slave can be configured either using an activemq.xml and a BrokerFactoryBean or it can be configured completely programmatically using Java code. You'd just need to instantiate and configure the correct Java classes for the persistence of your choice. Bruce -- perl -e 'print unpack("u30","D0G)u8...@4vyy9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*" );' Apache ActiveMQ - http://activemq.apache.org/ Apache Camel - http://camel.apache.org/ Apache ServiceMix - http://servicemix.apache.org/ Blog: http://bruceblog.org/