activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jiang <zju_...@163.com>
Subject Re: How to create BrokerService
Date Wed, 16 May 2007 06:24:29 GMT

bsnyder thanks a lot. 
In fact I just want to admin ActiveMQ from remote admin tools(which written
by myself). I want to add/remove destinations on that  MQ server .  From my
opinion, I think I should first get a referece of the remote server ,then I
can do some operations on the server through that ref ( What I do is not
create the broker really , In fact it has been created and run on the server
when Activemq server starts.I just use it .Maybe what I think is wrong). So
I connect to the broker at first step use the original code BrokerService
service = BrokerFactory.createBroker(new URI("xxxxx")); or maybe the code
you write for example , then I will use the code below:
     ActiveMQDestination[] destinations = service.getDestinations();  //to
get destinations list
     BrokerView brview = service.getAdminView();    //get the admin
BrokerView
     brview.addTopic("Hello");    //add Hello topic to the broker --- Step 1
     brview.addTopic("World");  //add World topic to the broker---Step 2
     brview.removeTopic("Hello");  //remove Hello topic from the
broker---Step3
    brview.removeTopic("World");  //remove World topic from the
broker---Step 4
All the add/remove actions can been seen from the jconsole (after Step1 , we
can seen from jconsole that Hello Topic has been added. after Step2 we can
seen World topic has been added. after Step3 Hello topic can been seen
removed. after Step4 just as Step3 )

bsnyder what I say is right ? (Now the code I wirte above has not been
tested for lack of environment. I will test it late )
Thanks.	  

bsnyder wrote:
> 
> 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/
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-create-BrokerService-tf3762284s2354.html#a10635961
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Mime
View raw message