问题
I am using tomcat as webserver. Planning to use active mq for messaging purpose. Just started learning about jms and activeMQ. Gone thru https://activemq.apache.org/getting-started.html. What i have got is active mq comes with its own web server(probably apache IS not sure). My question is what if I want to use existing tomcat server instead of installing new server for active mq. Is it possible?
UPDATE: i think i can itegrate existing tomcat with https://activemq.apache.org/tomcat.html
回答1:
Yes Apache ActiveMQ is a light-weight broker, so you can deploy it in Apache Tomcat as a WAR file. Or try Apache TomEE which comes out of the box with AcitveMQ.
http://tomee.apache.org/apache-tomee.html
If you deploy ActiveMQ as a WAR file then it does not come with its own web service, its only the standalone distribution of ActiveMQ that comes with Jetty as its web server. You just don't need to include Jetty in your WAR file with ActiveMQ embedded.
At Apache Camel we have an example of a WAR file with ActiveMQ and Camel as a WAR file you can deploy in Tomcat. You can take a look, and just remove Camel from the example:
http://camel.apache.org/activemq-camel-tomcat.html
回答2:
See these:
http://blog.octera.info/2011/06/how-to-embed-activemq-in-tomcat/
http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html
Basically, you just start a broker in your web application. If you need to retrieve some resource like ConnectionFactory or Destination(Queue/Topic), you can use Tomcat JNDI support to do this.
来源:https://stackoverflow.com/questions/22890247/integrating-existing-tomcat-server-with-active-mq