activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bruce Snyder" <bruce.sny...@gmail.com>
Subject Re: How to create BrokerService
Date Wed, 16 May 2007 03:31:32 GMT
On 5/15/07, Jiang <zju_jjc@163.com> wrote:
>
> I find BrokerFactory can create Broker. The method is createBroker(URI). If I
> start one ActiveMQ Server on localhost and in Activemq.xml  open
>        <transportConnector name="openwire" uri="tcp://localhost:61616"
> discoveryUri="multicast://default"/>
>        <transportConnector name="ssl"     uri="ssl://localhost:61617"/>
>        <transportConnector name="stomp"   uri="stomp://localhost:61613"/>
>     <managementContext>
>        <managementContext connectorPort="1099"
> jmxDomainName="org.apache.activemq"/>
>     </managementContext>
> Then BrokerService service = BrokerFactory.createBroker(new URI("xxxxx"));
> here URI("xxxxx") what should I specific xxxxx  to connect to the ActiveMQ
> server above?(What I mean is whether I can use createBroker to connect to
> the Activemq server . Then I can get information about the server and admin
> the server )

You can just use the URI for the transport connector you'd like the
BrokerFactory to use from your configuration file. Below is an example
of this:

BrokerService service = BrokerFactory.createBroker(new
URI("tcp://localhost:61616"));

But I'm curious to know what exactly are you trying to do? If you're
just trying to create a broker, it's much easier to create a
BrokerService object and then just call getBroker() method to grab the
actual Broker object (if you really need the Broker object - I'm
willing to be you don't need it, but I could be wrong). Below is an
example of this:

BrokerService brokerService = new BrokerService();
brokerService.setUseJmx(true);
brokerService.addConnector("tcp://localhost:61616");
brokerService.start();

Another option is to use the BrokerFactoryBean and a standard
activemq.xml configuration file. Below is an example of this:

BrokerFactoryBean factoryBean = new BrokerFactoryBean(new
ClassPathResource("org/apache/servicemix/jms/activemq.xml"));
factoryBean.afterPropertiesSet();
Broker broker = bfb.getBroker();
broker.start();

Hope this helps.

Bruce
-- 
perl -e 'print unpack("u30","D0G)U8V4\@4VYY9&5R\"F)R=6-E+G-N>61E<D\!G;6%I;\"YC;VT*"
);'

Apache Geronimo - http://geronimo.apache.org/
Apache ActiveMQ - http://activemq.org/
Apache ServiceMix - http://servicemix.org/
Castor - http://castor.org/

Mime
View raw message