You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by Henk van Voorthuijsen <vo...@xs4all.nl> on 2007/07/09 17:39:35 UTC

Trying to get started: how do I configure Tomcat to run ActiveMQ?

After downloading ActiveMQ 4.1.1, I managed to sucessfully run it as
stand-alone.
As a following step, I tried to get Tomcat to start the same process - and
that's where I get lost!

I have tried adding a ConnectionFactory and Queue to the
<GlobalNamingResources> element, and they do show up on the resource page of
the Tomcat manager, but so far I can see no processes being started.

A step-by-step description of how to do this would be much appreciated.

Henk van Voorthuijsen

PS. My configuration:
Windows XP
Tomcat 5.5.17
ActiveMQ 4.1.1


-- 
View this message in context: http://www.nabble.com/Trying-to-get-started%3A-how-do-I-configure-Tomcat-to-run-ActiveMQ--tf4050129s2354.html#a11504140
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


RE: Trying to get started: how do I configure Tomcat to run ActiveMQ?

Posted by "Suchitha Koneru (sukoneru)" <su...@cisco.com>.
There is this link for vm transport as well 
http://activemq.apache.org/vm-transport-reference.html 

-----Original Message-----
From: Suchitha Koneru (sukoneru) 
Sent: Monday, July 09, 2007 12:31 PM
To: users@activemq.apache.org
Subject: RE: Trying to get started: how do I configure Tomcat to run
ActiveMQ?

The approach which I used for starting active mq broker via Tomcat
server is  as follows 

1) Include the connection factory for starting the active mq broker in
Tomcat/conf/context.xml as follows

      <Resource
        	name="jms/ConnectionFactory"
        	auth="Container"
        	type="org.apache.activemq.ActiveMQConnectionFactory"
        	description="JMS Connection Factory"
       	 	factory="org.apache.activemq.jndi.JNDIReferenceFactory"
 
brokerURL="vm://localhost?brokerConfig=xbean:activemq.xml"
			 
       />			
Make sure that activemq.xml should be present in the classpath of
Tomcat.  You can also specify brokerConfig as
brokerConfig=xbean:file:./activemq.xml.  


3)The active mq jars should be placed under (Tomcat/common/lib) of
Tomcat 


4)The Queues/Topics can be defined under  Tomcat/conf/context.xml.
      <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"/>      




5) The code for connecting to the broker is as follows 
     	
	Ictx = new javax.naming.InitialContext();
	envContext = (Context) Ictx.lookup("java:comp/env");
		TopicConnectionFactory  sampleconnectionFactory =
	
(TopicConnectionFactoryenvContext.lookup("jms/ConnectionFactory");




The broker is created and started when the first attempt to connect to
the broker is made.

Thanks,
Suchitha.

-----Original Message-----
From: Sandeep Chayapathi [mailto:sandeep@wssource.com] 
Sent: Monday, July 09, 2007 8:51 AM
To: users@activemq.apache.org
Subject: Re: Trying to get started: how do I configure Tomcat to run
ActiveMQ?


Hi,
 Im not sure if activemq can be started via tomcat, however I know you
can publish/subscribe to activemq topics/queue over web interface. You
need to copy/link few of the jar files in activemq/lib and
activemq/lib/optional to tomcat's lib folder.

 Then in tomcat's conf/web.xml:

1. add context params params for: org.apache.activemq.brokerURL and turn
on 
    org.apache.activemq.embeddedBroker

2. map REST servlets, mainly the : org.apache.activemq.web.AjaxServlet
and 
    org.apache.activemq.web.MessageServlet

3. map url to the above servlets, by practise, you can use /amq and
/message

for further help, checkout the
https://svn.apache.org/repos/asf/activemq/trunk/activemq-web-demo/
activemq-web-demo 

- Sandeep
 

Henk van Voorthuijsen wrote:
> 
> After downloading ActiveMQ 4.1.1, I managed to sucessfully run it as 
> stand-alone.
> As a following step, I tried to get Tomcat to start the same process -

> and that's where I get lost!
> 
> I have tried adding a ConnectionFactory and Queue to the 
> <GlobalNamingResources> element, and they do show up on the resource 
> page of the Tomcat manager, but so far I can see no processes being
started.
> 
> A step-by-step description of how to do this would be much
appreciated.
> 
> Henk van Voorthuijsen
> 
> PS. My configuration:
> Windows XP
> Tomcat 5.5.17
> ActiveMQ 4.1.1
> 
> 
> 

--
View this message in context:
http://www.nabble.com/Trying-to-get-started%3A-how-do-I-configure-Tomcat
-to-run-ActiveMQ--tf4050129s2354.html#a11504393
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Trying to get started: how do I configure Tomcat to run ActiveMQ?

Posted by Bruce Snyder <br...@gmail.com>.
On 7/19/07, Henk van Voorthuijsen <vo...@xs4all.nl> wrote:
>
> It all looks very sensible - however, all how-to's I encountered so far tell
> me how to configure a broker, or a receiver or a sender - but not together!
>
> So now the question becomes: how do I set up a sender and receiver so that
> they can actually communicate (using JNDI lookup if possible)?

Well you send messages to a queue using a JMS producer and consume
them from the same queue using a JMS consumer. There are examples of
each of these in the examples directory of ActiveMQ. They work right
out of the box if your run them like this:

1) In one terminal, start up ActiveMQ:

$ ./bin/activemq

2) In a second terminal, run the JMS producer:

$ cd <ACTIVEMQ-HOME>/examples
$ ant producer

3) In the second terminal, now run the JMS consumer:

$ ant consumer

This will demonstrate producing messages to a queue named TEST.FOO and
consuming messages from the same queue. This is how the producer and
the consumer communicate - via the queue.

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/

Re: Trying to get started: how do I configure Tomcat to run ActiveMQ?

Posted by Henk van Voorthuijsen <vo...@xs4all.nl>.
It all looks very sensible - however, all how-to's I encountered so far tell
me how to configure a broker, or a receiver or a sender - but not together!

So now the question becomes: how do I set up a sender and receiver so that
they can actually communicate (using JNDI lookup if possible)?
-- 
View this message in context: http://www.nabble.com/Trying-to-get-started%3A-how-do-I-configure-Tomcat-to-run-ActiveMQ--tf4050129s2354.html#a11691582
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Trying to get started: how do I configure Tomcat to run ActiveMQ?

Posted by Bruce Snyder <br...@gmail.com>.
On 7/9/07, Suchitha Koneru (sukoneru) <su...@cisco.com> wrote:
> The approach which I used for starting active mq broker via Tomcat
> server is  as follows
>
> 1) Include the connection factory for starting the active mq broker in
> Tomcat/conf/context.xml as follows
>
>       <Resource
>                 name="jms/ConnectionFactory"
>                 auth="Container"
>                 type="org.apache.activemq.ActiveMQConnectionFactory"
>                 description="JMS Connection Factory"
>                 factory="org.apache.activemq.jndi.JNDIReferenceFactory"
>
> brokerURL="vm://localhost?brokerConfig=xbean:activemq.xml"
>
>        />
> Make sure that activemq.xml should be present in the classpath of
> Tomcat.  You can also specify brokerConfig as
> brokerConfig=xbean:file:./activemq.xml.
>
>
> 3)The active mq jars should be placed under (Tomcat/common/lib) of
> Tomcat
>
>
> 4)The Queues/Topics can be defined under  Tomcat/conf/context.xml.
>       <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"/>
>
>
>
>
> 5) The code for connecting to the broker is as follows
>
>         Ictx = new javax.naming.InitialContext();
>         envContext = (Context) Ictx.lookup("java:comp/env");
>                 TopicConnectionFactory  sampleconnectionFactory =
>
> (TopicConnectionFactoryenvContext.lookup("jms/ConnectionFactory");
>
>
>
>
> The broker is created and started when the first attempt to connect to
> the broker is made.
>
> Thanks,
> Suchitha.
>
> -----Original Message-----
> From: Sandeep Chayapathi [mailto:sandeep@wssource.com]
> Sent: Monday, July 09, 2007 8:51 AM
> To: users@activemq.apache.org
> Subject: Re: Trying to get started: how do I configure Tomcat to run
> ActiveMQ?
>
>
> Hi,
>  Im not sure if activemq can be started via tomcat, however I know you
> can publish/subscribe to activemq topics/queue over web interface. You
> need to copy/link few of the jar files in activemq/lib and
> activemq/lib/optional to tomcat's lib folder.
>
>  Then in tomcat's conf/web.xml:
>
> 1. add context params params for: org.apache.activemq.brokerURL and turn
> on
>     org.apache.activemq.embeddedBroker
>
> 2. map REST servlets, mainly the : org.apache.activemq.web.AjaxServlet
> and
>     org.apache.activemq.web.MessageServlet
>
> 3. map url to the above servlets, by practise, you can use /amq and
> /message
>
> for further help, checkout the
> https://svn.apache.org/repos/asf/activemq/trunk/activemq-web-demo/
> activemq-web-demo
>
> - Sandeep
>
>
> Henk van Voorthuijsen wrote:
> >
> > After downloading ActiveMQ 4.1.1, I managed to sucessfully run it as
> > stand-alone.
> > As a following step, I tried to get Tomcat to start the same process -
>
> > and that's where I get lost!
> >
> > I have tried adding a ConnectionFactory and Queue to the
> > <GlobalNamingResources> element, and they do show up on the resource
> > page of the Tomcat manager, but so far I can see no processes being
> started.
> >
> > A step-by-step description of how to do this would be much
> appreciated.
> >
> > Henk van Voorthuijsen
> >
> > PS. My configuration:
> > Windows XP
> > Tomcat 5.5.17
> > ActiveMQ 4.1.1

This is great info for others in the community. It would really be
great if you could add more detail to the Tomcat page on the ActiveMQ
website:

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

Just register for a wiki account here:

http://cwiki.apache.org/confluence/signup.action

And as soon as that is complete, you can start adding or editing pages
on the wiki.

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/

RE: Trying to get started: how do I configure Tomcat to run ActiveMQ?

Posted by "Suchitha Koneru (sukoneru)" <su...@cisco.com>.
The approach which I used for starting active mq broker via Tomcat
server is  as follows 

1) Include the connection factory for starting the active mq broker in
Tomcat/conf/context.xml as follows

      <Resource
        	name="jms/ConnectionFactory"
        	auth="Container"
        	type="org.apache.activemq.ActiveMQConnectionFactory"
        	description="JMS Connection Factory"
       	 	factory="org.apache.activemq.jndi.JNDIReferenceFactory"
 
brokerURL="vm://localhost?brokerConfig=xbean:activemq.xml"
			 
       />			
Make sure that activemq.xml should be present in the classpath of
Tomcat.  You can also specify brokerConfig as 
brokerConfig=xbean:file:./activemq.xml.  


3)The active mq jars should be placed under (Tomcat/common/lib) of
Tomcat 


4)The Queues/Topics can be defined under  Tomcat/conf/context.xml.
      <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"/>      




5) The code for connecting to the broker is as follows 
     	
	Ictx = new javax.naming.InitialContext();
	envContext = (Context) Ictx.lookup("java:comp/env");
		TopicConnectionFactory  sampleconnectionFactory =
	
(TopicConnectionFactoryenvContext.lookup("jms/ConnectionFactory");




The broker is created and started when the first attempt to connect to
the broker is made.

Thanks,
Suchitha.

-----Original Message-----
From: Sandeep Chayapathi [mailto:sandeep@wssource.com] 
Sent: Monday, July 09, 2007 8:51 AM
To: users@activemq.apache.org
Subject: Re: Trying to get started: how do I configure Tomcat to run
ActiveMQ?


Hi,
 Im not sure if activemq can be started via tomcat, however I know you
can publish/subscribe to activemq topics/queue over web interface. You
need to copy/link few of the jar files in activemq/lib and
activemq/lib/optional to tomcat's lib folder.

 Then in tomcat's conf/web.xml:

1. add context params params for: org.apache.activemq.brokerURL and turn
on 
    org.apache.activemq.embeddedBroker

2. map REST servlets, mainly the : org.apache.activemq.web.AjaxServlet
and 
    org.apache.activemq.web.MessageServlet

3. map url to the above servlets, by practise, you can use /amq and
/message

for further help, checkout the
https://svn.apache.org/repos/asf/activemq/trunk/activemq-web-demo/
activemq-web-demo 

- Sandeep
 

Henk van Voorthuijsen wrote:
> 
> After downloading ActiveMQ 4.1.1, I managed to sucessfully run it as 
> stand-alone.
> As a following step, I tried to get Tomcat to start the same process -

> and that's where I get lost!
> 
> I have tried adding a ConnectionFactory and Queue to the 
> <GlobalNamingResources> element, and they do show up on the resource 
> page of the Tomcat manager, but so far I can see no processes being
started.
> 
> A step-by-step description of how to do this would be much
appreciated.
> 
> Henk van Voorthuijsen
> 
> PS. My configuration:
> Windows XP
> Tomcat 5.5.17
> ActiveMQ 4.1.1
> 
> 
> 

--
View this message in context:
http://www.nabble.com/Trying-to-get-started%3A-how-do-I-configure-Tomcat
-to-run-ActiveMQ--tf4050129s2354.html#a11504393
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Re: Trying to get started: how do I configure Tomcat to run ActiveMQ?

Posted by Sandeep Chayapathi <sa...@wssource.com>.
Hi,
 Im not sure if activemq can be started via tomcat, however I know you can
publish/subscribe to activemq topics/queue over web interface. You need to
copy/link few of the jar files in activemq/lib and activemq/lib/optional to
tomcat's lib folder.

 Then in tomcat's conf/web.xml:

1. add context params params for: org.apache.activemq.brokerURL and turn on 
    org.apache.activemq.embeddedBroker

2. map REST servlets, mainly the : org.apache.activemq.web.AjaxServlet and 
    org.apache.activemq.web.MessageServlet

3. map url to the above servlets, by practise, you can use /amq and /message

for further help, checkout the 
https://svn.apache.org/repos/asf/activemq/trunk/activemq-web-demo/
activemq-web-demo 

- Sandeep
 

Henk van Voorthuijsen wrote:
> 
> After downloading ActiveMQ 4.1.1, I managed to sucessfully run it as
> stand-alone.
> As a following step, I tried to get Tomcat to start the same process - and
> that's where I get lost!
> 
> I have tried adding a ConnectionFactory and Queue to the
> <GlobalNamingResources> element, and they do show up on the resource page
> of the Tomcat manager, but so far I can see no processes being started.
> 
> A step-by-step description of how to do this would be much appreciated.
> 
> Henk van Voorthuijsen
> 
> PS. My configuration:
> Windows XP
> Tomcat 5.5.17
> ActiveMQ 4.1.1
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Trying-to-get-started%3A-how-do-I-configure-Tomcat-to-run-ActiveMQ--tf4050129s2354.html#a11504393
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: Trying to get started: how do I configure Tomcat to run ActiveMQ?

Posted by wbickford <wi...@yahoo.com>.
I got frustrated with trying to setup jndi configuration when trying to run
as an embedded server.  I'm using Resin (not Tomcat) - I configured directly
from a java startup servlet.  This might help if you just want to get it
running, probably would work with Tomcat.  Here's what I did:
1) Copied all jars from lib directory to my lib.  Did not use the optional
libs.
2) Created a startup servlet with this in the init() method:
        static BrokerService brokerService; ....
        BrokerFactoryBean factoryBean = new BrokerFactoryBean(new
          
FileSystemResource("/opt/resin/webapps/lc/WEB-INF/classes/com/sadromance/mq/activemq.xml"));
        factoryBean.afterPropertiesSet();
        brokerService = factoryBean.getBroker();
3) ** Think this was Resin-specific but had to 3 xalan, xerces libs and
related web.xml entries.
I also had problems using the example programs which had too much bloat in
them to get them running quickly, can provide much simplified versions of
these.

Henk van Voorthuijsen wrote:
> 
> After downloading ActiveMQ 4.1.1, I managed to sucessfully run it as
> stand-alone.
> As a following step, I tried to get Tomcat to start the same process - and
> that's where I get lost!
> 
> I have tried adding a ConnectionFactory and Queue to the
> <GlobalNamingResources> element, and they do show up on the resource page
> of the Tomcat manager, but so far I can see no processes being started.
> 
> A step-by-step description of how to do this would be much appreciated.
> 
> Henk van Voorthuijsen
> 
> PS. My configuration:
> Windows XP
> Tomcat 5.5.17
> ActiveMQ 4.1.1
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Trying-to-get-started%3A-how-do-I-configure-Tomcat-to-run-ActiveMQ--tf4050129s2354.html#a11692805
Sent from the ActiveMQ - User mailing list archive at Nabble.com.