Getting started with HornetQ 2.2.x in Maven?
sboscarine Aug 18, 2011 4:49 PMHello,
I need to prototype a new application using HornetQ and would like to learn how to use it. However, getting started is proving to be a bit trickier than expected.
Is there a simple example somewhere that uses HornetQ 2.2.x in Maven?
I found http://community.jboss.org/wiki/HornetQMavenExample and it was a great start and what I was looking for. It worked as expected with HornetQ 2.0.0.
However, I wanted to use the latest version and found porting it to be non-trivial. When I try to start EmbeddedServer (from the project) am getting the following error:
HornetQException[errorCode=104 message=Connector 'netty-connector' not found on the main configuration file]
... I assume this is some silly mistake on my part, as I am starting from literally no experience with this product and very little with other JMS providers.
Here's what I did to get there:
- I updated the version of HornetQ to 2.2.7
- I updated Netty to 3.2.3.Final
- I removed hornetq-transports per https://issues.jboss.org/browse/HORNETQ-278 as it appears it was merged into hornetq-core.
- I also removed hornetq-logging, assuming similar logic
Here's my test:
import org.hornetq.core.config.impl.FileConfiguration; import org.hornetq.core.server.HornetQServer; import org.hornetq.core.server.HornetQServers; import org.hornetq.jms.server.JMSServerManager; import org.hornetq.jms.server.impl.JMSServerManagerImpl; import org.testng.annotations.*; @Test public class Simplest{ JMSServerManager jmsServerManager; @BeforeClass public void beforeClass() { try { FileConfiguration configuration = new FileConfiguration(); configuration.setConfigurationUrl("hornetq-configuration.xml"); configuration.start(); HornetQServer server = HornetQServers.newHornetQServer(configuration); jmsServerManager = new JMSServerManagerImpl(server, "hornetq-jms.xml"); // if you want to use JNDI, simple inject a context here or don't call this method and make sure the JNDI // parameters are set. jmsServerManager.setContext(null); jmsServerManager.start(); System.out.println("STARTED::"); } catch (Throwable e) { System.out.println("FAILED::"); e.printStackTrace(); } } public void test(){ System.out.println("Hello World"); } @AfterClass public void afterClass() throws Exception { jmsServerManager.stop(); } }
It works in 2.0.0 and fails in my 2.2.7 port.
Here's the full output:
RemoteTestNG starting Aug 18, 2011 4:42:06 PM org.hornetq.core.logging.impl.JULLogDelegate warn WARNING: AIO wasn't located on this platform, it will fall back to using pure Java NIO. If your platform is Linux, install LibAIO to enable the AIO journal Aug 18, 2011 4:42:06 PM org.hornetq.core.logging.impl.JULLogDelegate info INFO: live server is starting with configuration HornetQ Configuration (clustered=false,backup=false,sharedStore=true,journalDirectory=data/journal,bindingsDirectory=data/bindings,largeMessagesDirectory=data/largemessages,pagingDirectory=data/paging) Aug 18, 2011 4:42:06 PM org.hornetq.core.logging.impl.JULLogDelegate warn WARNING: Security risk! It has been detected that the cluster admin user and password have not been changed from the installation default. Please see the HornetQ user guide, cluster chapter, for instructions on how to do this. Aug 18, 2011 4:42:06 PM org.hornetq.core.logging.impl.JULLogDelegate info INFO: trying to deploy queue perfQueue Aug 18, 2011 4:42:07 PM org.hornetq.core.logging.impl.JULLogDelegate info INFO: trying to deploy queue jms.queue.exampleQueue Aug 18, 2011 4:42:07 PM org.hornetq.core.logging.impl.JULLogDelegate error SEVERE: Unable to deploy node [connection-factory: null] ConnectionFactory HornetQException[errorCode=104 message=Connector 'netty-connector' not found on the main configuration file] at org.hornetq.jms.server.impl.JMSServerManagerImpl.internalCreateCFPOJO(JMSServerManagerImpl.java:1167) at org.hornetq.jms.server.impl.JMSServerManagerImpl.internalCreateCF(JMSServerManagerImpl.java:1111) at org.hornetq.jms.server.impl.JMSServerManagerImpl.access$1000(JMSServerManagerImpl.java:98) at org.hornetq.jms.server.impl.JMSServerManagerImpl$3.runException(JMSServerManagerImpl.java:977) at org.hornetq.jms.server.impl.JMSServerManagerImpl.runAfterActive(JMSServerManagerImpl.java:1643) at org.hornetq.jms.server.impl.JMSServerManagerImpl.createConnectionFactory(JMSServerManagerImpl.java:966) at org.hornetq.jms.server.impl.JMSServerDeployer.deployConnectionFactory(JMSServerDeployer.java:186) at org.hornetq.jms.server.impl.JMSServerDeployer.createAndBindObject(JMSServerDeployer.java:112) at org.hornetq.jms.server.impl.JMSServerDeployer.deploy(JMSServerDeployer.java:99) at org.hornetq.core.deployers.impl.XmlDeployer.deploy(XmlDeployer.java:181) at org.hornetq.core.deployers.impl.FileDeploymentManager.registerDeployer(FileDeploymentManager.java:131) at org.hornetq.core.deployers.impl.XmlDeployer.start(XmlDeployer.java:210) at org.hornetq.jms.server.impl.JMSServerManagerImpl.activated(JMSServerManagerImpl.java:225) at org.hornetq.core.server.impl.HornetQServerImpl.callActivateCallbacks(HornetQServerImpl.java:1249) at org.hornetq.core.server.impl.HornetQServerImpl.initialisePart2(HornetQServerImpl.java:1506) at org.hornetq.core.server.impl.HornetQServerImpl.access$100(HornetQServerImpl.java:134) at org.hornetq.core.server.impl.HornetQServerImpl$NoSharedStoreLiveActivation.run(HornetQServerImpl.java:319) at org.hornetq.core.server.impl.HornetQServerImpl.start(HornetQServerImpl.java:578) at org.hornetq.jms.server.impl.JMSServerManagerImpl.start(JMSServerManagerImpl.java:269) at ***.Simplest.beforeClass(Simplest.java:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:80) at org.testng.internal.Invoker.invokeConfigurationMethod(Invoker.java:537) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:206) at org.testng.internal.Invoker.invokeConfigurations(Invoker.java:132) at org.testng.internal.TestMethodWorker.invokeBeforeClassMethods(TestMethodWorker.java:175) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:107) at org.testng.TestRunner.privateRun(TestRunner.java:754) at org.testng.TestRunner.run(TestRunner.java:614) at org.testng.SuiteRunner.runTest(SuiteRunner.java:335) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:330) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:292) at org.testng.SuiteRunner.run(SuiteRunner.java:241) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1169) at org.testng.TestNG.runSuitesLocally(TestNG.java:1094) at org.testng.TestNG.run(TestNG.java:1006) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:107) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:199) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:170) Aug 18, 2011 4:42:07 PM org.hornetq.core.logging.impl.JULLogDelegate info INFO: Started Netty Acceptor version 3.2.3.Final-r${buildNumber} localhost:5445 for CORE protocol Aug 18, 2011 4:42:07 PM org.hornetq.core.logging.impl.JULLogDelegate info INFO: Server is now live Aug 18, 2011 4:42:07 PM org.hornetq.core.logging.impl.JULLogDelegate info INFO: HornetQ Server version 2.2.7.Final (HQ_2_2_7_FINAL_AS7, 121) [678cc85d-c9c3-11e0-bfce-5c260a0f7d57] started STARTED:: Hello World Aug 18, 2011 4:42:07 PM org.hornetq.core.logging.impl.JULLogDelegate info INFO: HornetQ Server version 2.2.7.Final (HQ_2_2_7_FINAL_AS7, 121) [678cc85d-c9c3-11e0-bfce-5c260a0f7d57] stopped PASSED: test