Hi Denez , 

You could try out the following .  The broker is  configured as follows
in our application.

In our application , there are two web apps and the inter web app
communication is via the active mq broker. Out application uses active
mq 4.1.1 , java 1.6 and  Tomcat5.5.20

1) The jndi resources for active mq can be specified in
Tomcat/conf/context.xml
           
<!-- active mq connection factory -->
<Resource
                 name="jms/ConnectionFactory"
                 auth="Container"
                 type="org.apache.activemq.ActiveMQConnectionFactory"
                 description="JMS Connection Factory"
                 factory="org.apache.activemq.jndi.JNDIReferenceFactory"

 
brokerURL="tcp://ipaddress:61616?trace=true&wireFormat.maxInactivityDura
tion=-1"    
  /> 


 the flag  wireFormat.maxInactivityDuration should be set to -1 because
, if there is no activity (exchange os messages via the broker for some
period of Time) , the broker automatically closes down the connection.



<!-- topics -->


 <Resource name="jms/TopicOne" 
                  auth="Container" 
                  type="org.apache.activemq.command.ActiveMQTopic" 
                  description="the topic against which the client back
end will publish and server back end would subscribe"
 
factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
                  physicalName="FOO1.BAR"/>        
        
        
      <Resource name="jms/TopicTwo" 
                  auth="Container" 
                  type="org.apache.activemq.command.ActiveMQTopic" 
                  description="the topic against which the server back
end will publish and client back end would subscribe"
 
factory="org.apache.activemq.jndi.JNDIReferenceFactory" 
                  physicalName="FOO2.BAR"/>      
        
2) I have used broker configuration URI for the broker.  The alternative
approache  is using an activemq.xml file . If you use active.xml file ,
the broker url would be
brokerURL="tcp://localhost?brokerConfig=xbean:file:../../activemq.xml  ,
provide the relative path to the activemq.xml file , starting from the
bin directory of Tomcat. I am assuming that you are using "startup.bat"
present in the bin directory to start the tomcat server.


 The pseudo code for starting the broker is 
     
         BrokerService broker = new BrokerService();
// the connector should have the same contents as the broker url
        
broker.addConnector("tcp://ipaddress:61616?trace=true&wireFormat.maxInac
tivityDuration=-1");

        broker.start();

3) You can place the code for starting the broker in a singleton class .
The Constructor of the singleTonClass should create the broker. There
should also be a  synchronized method  for shutting down the broker.
For reference let us call this class as ActiveMQBroker.java .Place this
class under shared/classes folder  and  also place  , the active mq jars
in shared/lib;

When your web app needs to communicate with the broker, it will Create
an instance of  single Ton class ActiveMQBroker  . The pseudo code to be
placed in web apps to connect to the broker is 


                 SingleTonClass.getInstance();
                  Ictx = new javax.naming.InitialContext();
                        envContext = (Context)
Ictx.lookup("java:comp/env");
                TopicConnectionFactory  topicfactory
=(TopicConnectionFactory) conContext.lookup("jms/ConnectionFactory");
 
TopicConnection tConnection = topicfactory.createTopicConnection();

    // create session 

ActiveMQSession topicSession = (ActiveMQSession )
HConn.createSession(false, Session.AUTO_ACKNOWLEDGE);

        // create Topic 
Topic topic = (Topic)envContext.lookup(jms/TopicTwo);


                    // create either  a publisher or subscriber 
 
      topicSession.createSubscriber(topic);  

//In case of the subscriber , please implement the  MessageListner
Interface () 


4) You can also connect to the broker without using jndi resources.


Also these urls would be useful.
http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.h
tml

http://activemq.apache.org/broker-configuration-uri.html

http://fabien.carrion.free.fr/tomcat/jndi-jms-examples-howto.xml

http://activemq.apache.org/setting-up-activemq-with-tomcat-559.html

Thanks,
Suchitha.
  

-----Original Message-----
From: denez [mailto:[EMAIL PROTECTED] 
Sent: Monday, August 13, 2007 5:30 AM
To: users@activemq.apache.org
Subject: Re: How to monitor ActiveMQ that running on JBoss


Could you tell me what have you done to made it possible ?
I have no idea about how connect this two different server !
Thanks,
Regards,
Denez


ferry97 wrote:
> 
> Hi Denez,
> I run in under JBoss 4.2.0 GA. I have no idea on how to run it under 
> Tomcat.
> Perhaps you can post the error first, and see if I can help Regards, 
> Ferry
> 
> 
> 
> denez wrote:
>> 
>> Hi,
>> 
>> Which configuration have you made to run ActiveMQ under JBOSS ?
>> I try to run ActiveMQ under Tomcat but without success for the moment
!
>> Could you help me ?
>> 
>> Thanks,
>> Denez
>> 
>> 
>> ferry97 wrote:
>>> 
>>> Hi,
>>> I search from the help that to monitor the ActiveMQ we can do it 
>>> from JConsole.
>>> I run ActiveMQ under JBoss, and I can not find the broker in
JConsole.
>>> Anyone know how to monitor ActiveMQ, I understand that we can 
>>> monitor it from JBoss' JMX-Console. But I find it is very difficult 
>>> to read the message. eg: (when I invoke browseMEssage()) :
>>> 
>>>
[javax.management.openmbean.CompositeDataSupport(compositeType=javax.man
agement.openmbean.
>>> CompositeType(name=org.apache.activemq.command.ActiveMQTextMessage,i
>>> tems=((itemName= 
>>> JMSCorrelationID,itemType=javax.management.openmbean.SimpleType(name
>>> =java.lang.String)), 
>>>
(itemName=JMSDeliveryMode,itemType=javax.management.openmbean.SimpleT...
..............
>>> 
>>> Any information appreciated.
>>> Thanks.
>>> Regards,
>>> Ferry
>>> 
>> 
>> 
> 
> 

--
View this message in context:
http://www.nabble.com/How-to-monitor-ActiveMQ-that-running-on-JBoss-tf42
59591s2354.html#a12125322
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Reply via email to