我正在使用动态 Web 项目中的 WEB-INF/resources.xml 文件配置 ActiveMQ 的嵌入式实例,该文件引用外部 activemq.xml 文件。ActiveMQ 使用放置在 Tomcat 的 {$CATALINA_HOME}/conf 目录中的 activemq.xml 的绝对路径按预期启动和运行。将activemq.xml 放入项目的WEB-INF 目录时,Tomcat 无法使用相对路径找到BrokerXmlConfig 文件。
- 是否可以将activemq.xml文件与WEB-INF目录下的项目一起打包?
- 如果可能,Tomcat如何解析文件的路径?
工作资源.xml
<resources>
<Resource id="jmsConnectionFactory" type="javax.jms.ConnectionFactory">
connectionMaxIdleTime = 15 Minutes
connectionMaxWaitTime = 5 seconds
poolMaxSize = 10
poolMinSize = 0
resourceAdapter = MyJmsResourceAdapter
transactionSupport = xa
</Resource>
<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
BrokerXmlConfig = xbean:file:/absolute/path/to/activemq.xml
ServerUrl = tcp://localhost:61616
</Resource>
<resources>
失败的资源.xml
<resources>
<Resource id="jmsConnectionFactory" type="javax.jms.ConnectionFactory">
connectionMaxIdleTime = 15 Minutes
connectionMaxWaitTime = 5 seconds
poolMaxSize = 10
poolMinSize = 0
resourceAdapter = MyJmsResourceAdapter
transactionSupport = xa
</Resource>
<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
BrokerXmlConfig = xbean:file:WEB-INF/activemq.xml
ServerUrl = tcp://localhost:61616
</Resource>
<resources>
其他不成功的尝试:
BrokerXmlConfig = xbean:classpath:WEB-INF/activemq.xml
BrokerXmlConfig = xbean:file:WEB-INF/activemq.xml
BrokerXmlConfig = xbean:file:activemq.xml
BrokerXmlConfig = xbean:file:./activemq.xml
BrokerXmlConfig = xbean:file:../activemq.xml
BrokerXmlConfig = xbean:file:conf/activemq.xml