ActiveMQ配置:BrokerXMLConfig activemq.xml-找不到相对路径文件

时间:2019-03-05 17:44:37

标签: activemq tomee-8

我正在使用动态Web项目中的WEB-INF / resources.xml文件配置ActiveMQ的嵌入式实例,该文件引用了外部activemq.xml文件。 ActiveMQ使用放置在Tomcat的{$ CATALINA_HOME} / conf目录中的activemq.xml的绝对路径来按预期方式启动和运行。将activemq.xml放入项目的WEB-INF目录中时,Tomcat无法使用相对路径找到BrokerXmlConfig文件。

  1. 是否可以将activemq.xml文件与项目一起打包在WEB-INF目录中?
  2. 如果可能,Tomcat如何解析文件的路径?

正在工作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:/absolute/path/to/activemq.xml
        ServerUrl       =  tcp://localhost:61616
    </Resource>
  <resources>

失败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

1 个答案:

答案 0 :(得分:0)

我从未解决过xbean相对路径问题。使用绝对路径有效

BrokerXmlConfig =  xbean:file:/absolute/path/to/activemq.xml

除了路径问题外,我最终没有使用单独的activemq.xml文件。我只是将连接工厂与默认JMS资源适配器一起使用。

  <resources>
    <Resource id="jmsConnectionFactory" type="javax.jms.ConnectionFactory">
        connectionMaxIdleTime = 15 Minutes
        connectionMaxWaitTime = 5 seconds
        poolMaxSize = 10
        poolMinSize = 0
        resourceAdapter = Default JMS Resource Adapter
        transactionSupport = xa
    </Resource>
  <resources>