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 Thu, 17 May 2007 05:47:07 GMT

bsnyder , thanks a lot . I see what you mean. 
I still have some questions need your help .
First question: After I create topic "Hello" in the broker use the code you
shown , I can see it in the jconsole. But when I use client code to find the
topic (use JNDI lookup, code below:)
Hashtable env = new Hashtable();
env.put(Context.INITIAL_CONTEXT_FACTORY,
"org.apache.activemq.jndi.ActiveMQInitialContextFactory");
env.put(Context.PROVIDER_URL, "tcp://serverip:61616");
Context ctx = new InitialContext(env);
ConnectionFactory connectionFactory = (ConnectionFactory)
ctx.lookup("ConnectionFactory"); //it will success
Destination des = (Destination)ctx.lookup("Hello");  //it throw exception
about name cannot be found
Maybe I need do something else about JNDI ???
Second question: I use normal code as ConnectionFactory / Connection/
Session/ Destination , just as show below: 
ActiveMQConnectionFactory factory = new
ActiveMQConnectionFactory("admin","admin","tcp://serverip:61616");
Connection connection = (Connection)factory.createConnection();
Session session = connection.createSession(false, 0);
Topic topic = session.createTopic("Hello");
MessageProducer producer = session.createProducer(topic);
I can see from jconsole, there are 3 items added in the Topic directory.
ActiveMQ.Advisory.Connection
ActiveMQ.Advisory.Producer.Topic.Hello
ActiveMQ.Advisory.Topic
But if I use jmx code . It will just add one item to the Topic directory .
Hello
After I add Hello to broker use JMX code after broker starts .I f I run
ActiveMQConnectionFactory factory = new
ActiveMQConnectionFactory("admin","admin","tcp://serverip:61616");
Connection connection = (Connection)factory.createConnection();
Session session = connection.createSession(false, 0);
Topic topic = session.createTopic("Hello");
MessageProducer producer = session.createProducer(topic);
Then other 3 item still be added to the Topic directory(there will be 4
items below Topic directory). I was confused about : Hello /
ActiveMQ.Advisory.Producer.Topic.Hello   , are they different ??? If JNDI
can find the Hello added use JMX ,then topic with name "Hello" stands for
which one ???( I think in client code , maybe we will just use Hello for
these 2 topics' name , do I wrong ?)
Any help is thanks.

bsnyder wrote:
> 
> On 5/16/07, Jiang <zju_jjc@163.com> wrote:
>>
>> bsnyder thanks a lot .The example you shown works well.  But I still have
>> a
>> question: In ActiveMQ , there is a broker.jmx package , in this package
>> there are a lot of classes such as BrokerView/QueryView and so on. I
>> think
>> if I use these classes many things will be easiyer. For example
>> DestinationView class , it has many method to use .But  its constructor
>> has
>> a ManagedRegionBroker , I don't no how to create one ManagedRegionBroker
>> object(Its constructor is so  complex , it need BrokerService and so on)
>> . I
>> do wonder whether I can use these classes to meet the need I mentioned
>> before(addTopic/removeTopic ...).
>>
>> public DestinationView(ManagedRegionBroker broker, Destination
>> destination){
>>         this.broker = broker;
>>         this.destination=destination;
>>     }
> 
> The View objects you mention are part of the ActiveMQ internals and
> are the actual MBeans that are get registered with the MBeanServer for
> various items internal to the ActiveMQ core architecture. These
> objects are not public JMX management APIs for ActiveMQ. The example
> that I provided demonstrates the use of the MBeanServerConnection to
> query for MBeans and to invoke methods. This is exactly what you
> should be using to mange ActiveMQ via JMX.
> 
> 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#a10658978
Sent from the ActiveMQ - Dev mailing list archive at Nabble.com.


Mime
View raw message