Reputation: 25830
I am creating an embedded ActiveMQ in Tomcat by the below context.xml. It specifies the config xml location in the broker url brokerURL="vm://localhost?brokerConfig=xbean:activemq.xml"
.
I have put the activemq.xml
at the base of my WAR file (so right next to WEB-INF in the WAR). Will it be found there?
MyWAR.war
WEB-INF/
beans.xml
activemq.xml
My context.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<!-- JMS Factory and Queue -->
<Resource auth="Container"
name="jms/ConnectionFactory"
type="org.apache.activemq.ActiveMQConnectionFactory"
description="JMS Connection Factory"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
brokerURL="vm://localhost?brokerConfig=xbean:activemq.xml"
brokerName="MyBroker"
useEmbeddedBroker="true"
trustAllPackages="true"
persistent="true"
/>
<Resource auth="Container"
name="jms/MyQueue"
type="org.apache.activemq.command.ActiveMQQueue"
description="Downtime Event JMS queue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="MyQueue"
persistent="true"
/>
<Resource auth="Container"
name="jms/MyQueueRetry"
type="org.apache.activemq.command.ActiveMQQueue"
description="Downtime Event JMS queue"
factory="org.apache.activemq.jndi.JNDIReferenceFactory"
physicalName="MyQueueRetry"
persistent="true"
/>
</Context>
EDIT: my updated activemq.xml:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<bean id="ioExceptionHandler" class="org.apache.activemq.util.DefaultIOExceptionHandler">
<property name="ignoreAllErrors"><value>true</value></property>
</bean>
<!-- MySql DataSource Sample Setup -->
<bean id="mysql-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/activemq"/>
<property name="username" value="testuser"/>
<property name="password" value="password"/>
<property name="poolPreparedStatements" value="true"/>
</bean>
<broker
xmlns="http://activemq.apache.org/schema/core"
persistent="true"
ioExceptionHandler="#ioExceptionHandler"
useShutdownHook="true"
useJmx="false"
brokerName="EventBroker"
>
<persistenceAdapter>
<jdbcPersistenceAdapter dataSource="#mysql-ds" />
</persistenceAdapter>
</broker>
</beans>
I also tried both of the following:
brokerURL="vm://localhost?brokerConfig=xbean:classpath:activemq.xml"
(And putting it in WEB-INF)
brokerURL="vm://localhost?brokerConfig=xbean:classpath:WEB-INF/activemq.xml"
It never uses MySQL.
Upvotes: 2
Views: 3532
Reputation: 25830
(Partially from the help of @Matt_Pavlovich)
You have to use the classpath:
key under the xbeans AND it has to be in a directory that can be found on the WAR classpath (e.g. META-INF):
brokerURL="vm://localhost?brokerConfig=xbean:classpath:META-INF/activemq.xml"
Upvotes: 1
Reputation: 4316
A couple ways..
Crank up the logging of org.apache.activemq to DEBUG or TRACE
Add an additional entry on an open port 61618.. confirm it is listening using netstat.
Also, you can connect up to JMX of the running JVM process and see the org.apache.activemq JMX beans present.
A couple references:
Upvotes: 1