8 Replies Latest reply on Jan 29, 2019 12:00 PM by Justin Bertram

    Hornetq 2.2.5 in Wildfly 12?

    Ram Natarajan Newbie

      Hi,

      We have an application on JBoss 5_1 and uses Hornetq 2.2.5. We are in the process of migrating the application to Wildfly 12 (or 14). I wanted to know if Wildfly 12 supports legacy Hornetq code/configurations. Please point me to any articles or examples that would help in this regard.

      If hornetq 2.2.5 would not work in Wildfly 12, then please point me to the steps that would help me migrate to the latest messaging service.

       

      thanks in advance.

      Ram

        • 1. Re: Hornetq 2.2.5 in Wildfly 12?
          Justin Bertram Master

          ActiveMQ Artemis, which ships in Wildfly 12 and is based on HornetQ, will still support legacy clients, but it won't necessarily support HornetQ configuration. However, the configuration elements are the same in many cases or very similar which should make migration fairly simple.  I don't know of any migration specific documentation.

          1 of 1 people found this helpful
          • 2. Re: Hornetq 2.2.5 in Wildfly 12?
            Ram Natarajan Newbie

            Thanks for the input. I am trying to take the approach of adding a messaging subsystem in standalone-full.xml (wildfly 12).

            I included an extension as:

            <extension module="org.jboss.as.messaging"/>

            ------<snipped>

            Then defined the <subsystem> using the above extension.

            <subsystem xmlns="urn:jboss:domain:messaging:2.0">

            <hornetq-server>

            .....

            </hornetq-server>

            </subsystem>

             

            During deployment in Wildfly 12, i get the message:

            ERROR [org.jboss.as.server] (Controller Boot Thread) WFLYSRV0055: Caught exception during boot: org.jboss.as.controller.persistence.ConfigurationPersistenceException: WFLYCTL0085: Failed to parse configuration

            at org.jboss.as.controller.persistence.XmlConfigurationPersister.load(XmlConfigurationPersister.java:143)

            <snip>

            Caused by: javax.xml.stream.XMLStreamException: WFLYCTL0083: Failed to load module org.jboss.as.messaging

            at org.jboss.as.controller.parsing.DeferredExtensionContext.load(DeferredExtensionContext.java:100)

            at org.jboss.as.server.parsing.StandaloneXml_6.readServerElement(StandaloneXml_6.java:240)

            <snip>

            ... 3 more

            Caused by: java.util.concurrent.ExecutionException: java.lang.UnsupportedOperationException: WFLYCTL0309: Legacy extension 'org.jboss.as.messaging' is not supported on servers running this version. The extension is only supported for use by hosts running a previous release in a mixed-version managed domain

             

            If extension module - org.jboss.as.messaging is not supported, what options do i have to do the <subsystem> configuration for hornetq-server.

             

            thanks in advance.

            Ram

            • 3. Re: Hornetq 2.2.5 in Wildfly 12?
              Justin Bertram Master

              Both Wildfly 12 & 14 already have a messaging subsystem based on Apache ActiveMQ Artemis so you don't need to add the old messaging subsystem based on HornetQ. Simply use the messaging subsystem that already exists.

              1 of 1 people found this helpful
              • 4. Re: Hornetq 2.2.5 in Wildfly 12?
                Ram Natarajan Newbie

                Ok, i agree with what you suggested. Found this information on compatibility of wildfly 10 (ActiveMQ) with legacy systems (HornetQ). WildFly Admin Guide 

                Here, i tried to do a POC on backward compatibility - where using Artemis S client in Wildfly 12, one is able to communicate with legacy Hornetq server.

                Here is my code snippet:

                    private static final String DEFAULT_CONNECTION_FACTORY = "connectionFactory.jms/ConnectionFactory";

                    private static final String INITIAL_CONTEXT_FACTORY = "org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory";

                    private static final String PROVIDER_URL = "tcp://127.0.0.1:5445?";

                 

                 

                    @Override

                    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

                        resp.setContentType("text/html");

                        PrintWriter out = resp.getWriter();

                      

                        try {

                            final Properties env = new Properties();

                            env.put(Context.INITIAL_CONTEXT_FACTORY, INITIAL_CONTEXT_FACTORY);

                            // env.put(Context.PROVIDER_URL,

                            // System.getProperty(Context.PROVIDER_URL, PROVIDER_URL));

                            env.setProperty("connectionFactory.jms/ConnectionFactory", "tcp://127.0.0.1:5445?");

                            env.setProperty("protocolManagerFactoryStr",

                                    "org.apache.activemq.artemis.core.protocol.hornetq.client.HornetQClientProtocolManagerFactory");

                            env.setProperty("queue.jms/exampleQueue", "exampleQueue");

                            /*

                             * connectionFactory.jms/ConnectionFactory=tcp://<legacy server

                             * address>:5445? \

                             * protocolManagerFactoryStr=org.apache.activemq.artemis.core.

                             * protocol.hornetq.client.HornetQClientProtocolManagerFactory

                             * queue.jms/myQueue=myQueue

                             */

                            namingContext = new InitialContext(env);

                            out.write("<p>Setting naming Context</p>");

                            // Perform the JNDI lookups

                            String connectionFactoryString = System.getProperty("connection.factory", DEFAULT_CONNECTION_FACTORY);

                            out.write("<p>Attempting to acquire connection factory \"" + connectionFactoryString + "\"</p>");

                            ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup("jms/ConnectionFactory");

                            log.info("Found connection factory " + connectionFactoryString + "\" in JNDI");

                 

                 

                            Destination destination = (Destination) namingContext.lookup("jms/exampleQueue");

                            log.info("Created Destination " + destination.toString() + ", now creating Connection.");

                 

                            Connection connection = connectionFactory.createConnection();

                            log.info("Created Connection " + connection.toString() + ", now creating session.");

                            Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

                            log.info("Created Session " + session.toString() + ", now creating MessageConsumer.");

                 

                 

                            MessageConsumer consumer = session.createConsumer(destination);

                            log.info("Created MessageConsumer " + consumer.toString() + ", now starting connection.");

                            connection.start();

                            log.info("Started connection " + session.toString() + ", now trying to consume message");

                            TextMessage receivedMessage = (TextMessage) consumer.receive();

                            log.info("Got queue message: " + receivedMessage.getText());

                The failure happens in bolded line -   Connection connection = connectionFactory.createConnection(); and the exception trace is:

                 

                ERROR [stderr] (default task-1) javax.jms.JMSException: Failed to create session factory

                ERROR [stderr] (default task-1) at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:757)

                ERROR [stderr] (default task-1) at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:265)

                ERROR [stderr] (default task-1) at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:260)

                ERROR [stderr] (default task-1) at org.jboss.as.quickstarts.servlet.TestServlet.doGet(TestServlet.java:132)

                ERROR [stderr] (default task-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:686)

                ERROR [stderr] (default task-1) at javax.servlet.http.HttpServlet.service(HttpServlet.java:791)

                <snip>

                org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1526)

                ERROR [stderr] (default task-1) at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)

                ERROR [stderr] (default task-1) at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:81)

                ERROR [stderr] (default task-1) at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)

                ERROR [stderr] (default task-1) at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:830)

                ERROR [stderr] (default task-1) at org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)

                ERROR [stderr] (default task-1) at org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985)

                ERROR [stderr] (default task-1) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)

                ERROR [stderr] (default task-1) at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1378)

                ERROR [stderr] (default task-1) at java.lang.Thread.run(Thread.java:745)

                ERROR [stderr] (default task-1) Caused by: ActiveMQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=AMQ119013: Timed out waiting to receive cluster topology. Group:null]

                ERROR [stderr] (default task-1) at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:803)

                ERROR [stderr] (default task-1) at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:755)

                ERROR [stderr] (default task-1) ... 46 more

                 

                I have added the jars containing the classes (org.apache.activemq.artemis.jndi.ActiveMQInitialContextFactory, org.apache.activemq.artemis.core.protocol.hornetq.client.HornetQClientProtocolManagerFactory) in the classpath.

                 

                Couple of questions:

                1. Should HornetQClientProtocolManagerFactory be loaded prior to creating connection? If so how should this class be loaded?

                2. What else am i missing in my code?

                 

                Thank you in advance.

                • 5. Re: Hornetq 2.2.5 in Wildfly 12?
                  Ram Natarajan Newbie

                  Apologies, i corrected

                  env.setProperty("connectionFactory.jms/ConnectionFactory", "tcp://127.0.0.1:5445?");

                   

                  to

                   

                  env.setProperty("connectionFactory.jms/ConnectionFactory", "tcp://127.0.0.1:5445?protocolManagerFactoryStr=org.apache.activemq.artemis.core.protocol.hornetq.client.HornetQClientProtocolManagerFactory");

                  After:

                  ConnectionFactory connectionFactory = (ConnectionFactory) namingContext.lookup("jms/ConnectionFactory");

                  i printed the toString() of connectionFactory object, which looks like this:

                   

                  ActiveMQConnectionFactory [serverLocator=ServerLocatorImpl [initialConnectors=[TransportConfiguration(name=jms/ConnectionFactory, factory=org-apache-activemq-artemis-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=localhost&protocolManagerFactoryStr=org-apache-activemq-artemis-core-protocol-hornetq-client-HornetQClientProtocolManagerFactory], discoveryGroupConfiguration=null], clientID=null, consumerWindowSize = 1048576, dupsOKBatchSize=1048576, transactionBatchSize=1048576, readOnly=false]

                   

                  But still, the subsequent line of

                  Connection connection = connectionFactory.createConnection();

                  fails with the same error:

                  javax.jms.JMSException: Failed to create session factory at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:757) at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:265) at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:260) at

                  <snip>

                  Caused by: ActiveMQNotConnectedException[errorType=NOT_CONNECTED message=AMQ119007: Cannot connect to server(s). Tried with all available servers.] at org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:787) at org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory.createConnectionInternal(ActiveMQConnectionFactory.java:755) ... 46 more

                   

                  Any suggestions to overcome the above error?

                   

                  thanks

                  Ram

                  • 6. Re: Hornetq 2.2.5 in Wildfly 12?
                    Justin Bertram Master

                    I think you're doing this backwards. Don't you have a legacy HornetQ client trying to connect to a Wildfly server using ActiveMQ Artemis?  What you've configured here is for a standalone ActiveMQ Artemis client which needs to connect to a legacy HornetQ server.

                     

                    I believe you need to configure your legacy HornetQ client to use the new JNDI properties for the Wildfly server and then deploy a legacy-connection-factory on the Wildfly server for your clients to use.

                    • 7. Re: Hornetq 2.2.5 in Wildfly 12?
                      Ram Natarajan Newbie

                      Hi,

                      Actually our test case is having a legacy Hornetq server (2.2.5) running and having WIldfly client connect to this legacy server (Hornetq). We are trying to test the backward compatibility use case mentioned in: WildFly Admin Guide

                      •       

                      Backward compatibility requires no configuration change in the legacy server.

                      WildFly 10 JMS clients do not look up resources on the legacy server but uses client-side JNDI to create their JMS resources. Artemis JMS client can then uses these resources to communicate with the legacy server using the HornetQ CORE protocol.

                       

                      Thanks

                      Ram

                       

                       

                      • 8. Re: Hornetq 2.2.5 in Wildfly 12?
                        Justin Bertram Master

                        This is completely different from what I understood originally from your previous comments/questions. In your use-case are you just running your application on Wildfly 12? Are you doing anything with ActiveMQ Artemis at all? If both of those things are true then you can simply deploy the HornetQ client jars to Wildfly and use them from your application just like you were before. You don't need to configure anything related to ActiveMQ Artemis or even deploy a messaging subsystem.