activemq - 使用共享嵌入式 ActiveMQ 在 Tomcat 7 中进行多次 war

标签 activemq tomcat7

我正在开发一个项目,我在 tomcat 7 中有几个 war 文件必须与同一个 Tomcat 中的单个嵌入式 activeMQ (5.5.1) 代理进行通信。

我想知道管理这个的最佳实践是什么,以及如何正确启动和停止代理。

实际上我尝试在 server.xml 中使用全局 JNDI 条目并在每次 war 中通过查找获取我的 activemq 连接。到代理的第一个连接隐式启动它。但是使用这种方法,我遇到了各种问题,例如实例已经存在或数据存储中的锁定。

我应该使用一个额外的 war ,它使用 BrokerFactory 显式启动代理吗?在这种情况下,如何确保这场 war 首先在 Tomcat 中执行?我如何停止我的经纪人以及在哪里?

谢谢您的帮助。

最佳答案

从文档...

If you are using the VM transport and wish to explicitly configure an Embedded Broker there is a chance that you could create the JMS connections first before the broker starts up. Currently ActiveMQ will auto-create a broker if you use the VM transport and there is not one already configured. (In 5.2 it is possible to use the waitForStart and create=false options for the connection uri)

So to work around this if you are using Spring you may wish to use the depends-on attribute so that your JMS ConnectionFactory depends on the embedded broker to avoid this happening. e.g.



请参阅这些页面了解更多信息...

http://activemq.apache.org/vm-transport-reference.html

http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html

http://activemq.apache.org/how-do-i-restart-embedded-broker.html

关于activemq - 使用共享嵌入式 ActiveMQ 在 Tomcat 7 中进行多次 war ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8353169/

相关文章:

java - HTTP 400 从 Apache HTTP 客户端执行多部分请求时

maven - JBOSS-作为-MAVEN-插件 :- Authentication Fails BUT Jboss-cli authentications?

tomcat - 服务器整夜闲置后出现 GSP 渲染问题

java - 使用 Apache ActiveMQ + XMPP(而不是普通 XMPP)进行消息传递

java - 您会使用发布/订阅或队列来进行长时间运行的后台进程吗?

jms - 持久交付和非持久交付之间的区别

jms - 如何从 JMS 队列中删除消息?

java - ActiveMQ - 无法回滚非事务 session INVIDUAL_ACK

java - 无法使 JAR/WAR 可执行文件与嵌入式 Tomcat 7 一起使用

tomcat7 - Tomcat 7-Servlet 3.0:常量池中的无效字节标记