Hello Gary,
Here's what I did:
1. added activemq.xml to classpath (classes/activemq.xml)
2. used xbean to initialize broker
String brokerURI = "xbean:activemq.xml";
ActiveMQConnectionFactory connectionFactory = new
ActiveMQConnectionFactory(brokerURI);
connection = connectionFactory.createConnection();
connection.start();
3. run the test.
The test fails on the "connection =
connectionFactory.createConnection();" line with the error:
javax.jms.JMSException: Could not create Transport. Reason:
java.io.IOException: Transport scheme NOT recognized: [xbean]
at
org.apache.activemq.util.JMSExceptionSupport.create(JMSExceptionSupport.java:35)
at
org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:245)
at
org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:258)
at
org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:230)
at
org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:178)
at
com.babelcentral.tallyho.gateway.messaging.MonitoringTest.initConnection(MonitoringTest.java:94)
at
com.babelcentral.tallyho.gateway.messaging.MonitoringTest.setUp(MonitoringTest.java:37)
at junit.framework.TestCase.runBare(TestCase.java:132)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:83)
at
org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.io.IOException: Transport scheme NOT recognized: [xbean]
at
org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:27)
at
org.apache.activemq.transport.TransportFactory.findTransportFactory(TransportFactory.java:204)
at
org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java:79)
at
org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:243)
... 19 more
Caused by: java.io.IOException: Could not find factory class for
resource: META-INF/services/org/apache/activemq/transport/xbean
at
org.apache.activemq.util.FactoryFinder$StandaloneObjectFactory.loadProperties(FactoryFinder.java:96)
at
org.apache.activemq.util.FactoryFinder$StandaloneObjectFactory.create(FactoryFinder.java:58)
at
org.apache.activemq.util.FactoryFinder.newInstance(FactoryFinder.java:146)
at
org.apache.activemq.transport.TransportFactory.findTransportFactory(TransportFactory.java:201)
... 21 more
-don
Gary Tully wrote:
Use the xbean: uri syntax to reference an xml configuration file in
your brokerURI, that is the most flexible way to configure an embedded
broker.
http://activemq.apache.org/broker-configuration-uri.html
On 16 September 2010 09:24, Don Santillan <donzym...@gmail.com> wrote:
Hello,
I am using activemq as a dependency in a web app. My web app is deployed to
a jetty server which is run through maven by issuing "mvn jetty:run".
Of course, one part of the web app is to create and start a broker. I am
doing this through ActiveMQConnectionFactory (as described at the last part
of
http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html,
titled "Using ActiveMQConnectionFactory"):
String brokerURI = "vm://testBroker?broker.persistent=false";
ActiveMQConnectionFactory cf = new ActiveMQConnectionFactory(brokerURI);
Connection connection = cf.createConnection();
connection.start();
Now, since I am running my web web app through maven, and activemq is used
as a library (not as a standalone app), I don't have an activemq.xml
configuration file. So, I don't know where to activate/enable
StatisticsBrokerPlugin as described at
http://activemq.apache.org/statisticsplugin.html:
<broker ...>
<plugins>
statisticsBrokerPlugin/>
</plugins>
</broker>
Also, since I am using ActiveMQConnectionFactory to create and start the
broker, I can't take advantage of setting the plugin through BrokerService:
BrokerPlugin plugin = new StatisticsBrokerPlugin();
BrokerPlugin[] plugins = {plugin};
BrokerService broker = new BrokerService();
try {
broker.addConnector(brokerURI);
broker.setPlugins(plugins);
broker.start();
} catch (Exception e) {
e.printStackTrace();
}
Now, my questions are:
1. How will I be able to set the StatisticsBrokerPlugin with the above
scenario?
2. Is there a way to get a reference to the broker to be able to set the
plugin?
3. Is there a way to add and use activemq.xml if it is used as a library and
run through maven? Set in pom.xml?
Please help. I really need this to work.
Thanks in advance.
-don