3 Replies Latest reply on Jul 30, 2014 11:37 AM by jbertram

    JBoss EAP 6.2 communication with HornetQ 2.4.0 Cluster

    ptenn10

      Hi All,

       

      I am trying to build a proof-of-concept.  In the spirit of Picture == 1000 words, here is my diagram for what I am attempting to setup:

       

      DIAGRAM_proof-of-concept.png

       

      I believe my cluster is working fine.  When I start HornetQ2 server, I see the following appear in my console:

       

      15:08:21,915 INFO  [org.hornetq.core.server] HQ221001: HornetQ Server version 2.5.0.SNAPSHOT (Wild Hornet, 124) [3ee2692f-079e-11e4-8041-d79979512c3d]

      15:08:27,588 INFO  [org.hornetq.core.server] HQ221027: Bridge ClusterConnectionBridge@5ff72860 [name=sf.my-cluster.0397bf96-078c-11e4-81ed-a581e45ee6da, queue=QueueImpl[name=sf.my-cluster.0397bf96-078c-11e4-81ed-a581e45ee6da, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=3ee2692f-079e-11e4-8041-d79979512c3d]]@5b7be7d8 targetConnector=ServerLocatorImpl (identity=(Cluster-connection-bridge::ClusterConnectionBridge@5ff72860 [name=sf.my-cluster.0397bf96-078c-11e4-81ed-a581e45ee6da, queue=QueueImpl[name=sf.my-cluster.0397bf96-078c-11e4-81ed-a581e45ee6da, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=3ee2692f-079e-11e4-8041-d79979512c3d]]@5b7be7d8 targetConnector=ServerLocatorImpl [initialConnectors=[TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=localhost], discoveryGroupConfiguration=null]]::ClusterConnectionImpl@1668999644[nodeUUID=3ee2692f-079e-11e4-8041-d79979512c3d, connector=TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=localhost, address=jms, server=HornetQServerImpl::serverUUID=3ee2692f-079e-11e4-8041-d79979512c3d])) [initialConnectors=[TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=localhost], discoveryGroupConfiguration=null]] is connected

       

      However, I cannot send messages to the cluster from my JBoss EAP 6.2 Server.  I modified the HelloWorldMDBServletClient from JBoss EAP Quickstarts helloworld-mdb:

       

       

          protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
              resp.setContentType("text/html");
              PrintWriter out = resp.getWriter();
              Connection connection = null;
              out.write("<h1>Quickstart: This example demonstrates the use of <strong>JMS 1.1</strong> and <strong>EJB 3.1 Message-Driven Bean</strong> in JBoss Enterprise Application 6.</h1>");
              try
              {
                  UDPBroadcastGroupConfiguration udpCfg = new UDPBroadcastGroupConfiguration("231.7.7.7", 9876, null, -1);
                  DiscoveryGroupConfiguration groupConfiguration = new DiscoveryGroupConfiguration(HornetQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT, HornetQClient.DEFAULT_DISCOVERY_INITIAL_WAIT_TIMEOUT, udpCfg);
                  ConnectionFactory connectionFactory = (ConnectionFactory)HornetQJMSClient.createConnectionFactoryWithHA(groupConfiguration, JMSFactoryType.CF);
      
      
                  Destination destination;
                  if (req.getParameterMap().keySet().contains("topic")) {
                      destination = HornetQJMSClient.createTopic("helloWorldTopic");
                  } else {
                      destination = HornetQJMSClient.createQueue("helloWorldQueue");
                  }
                  out.write("<p>Sending messages to <em>" + destination + "</em></p>");
                  connection = connectionFactory.createConnection();
                  Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
                  MessageProducer messageProducer = session.createProducer(destination);
                  connection.start();
                  out.write("<h2>Following messages will be send to the destination:</h2>");
                  TextMessage message = session.createTextMessage();
                  for (int i = 0; i < MSG_COUNT; i++) {
                      message.setText("This is message " + (i + 1));
                      messageProducer.send(message);
                      out.write("Message (" + i + "): " + message.getText() + "</br>");
                  }
                  out.write("<p><i>Go to your JBoss Application Server console or Server log to see the result of messages processing</i></p>");
      
      
              } catch (JMSException e) {
                  e.printStackTrace();
                  out.write("<h2>A problem occurred during the delivery of this message</h2>");
                  out.write("</br>");
                  out.write("<p><i>Go your the JBoss Application Server console or Server log to see the error stack trace</i></p>");
              } finally {
                  if (connection != null) {
                      try {
                          connection.close();
                      } catch (JMSException e) {
                          e.printStackTrace();
                      }
                  }
                  if (out != null) {
                      out.close();
                  }
              }
          }
      
      
      
      
      
      
      

       

      When I run the WAR and attempt to execute the Servlet, I get an error message:

       

      15:16:32,152 ERROR [stderr] (http-/127.0.0.1:8080-1) javax.jms.JMSException: Failed to create session factory

      15:16:32,155 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:676)

      15:16:32,158 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:115)

      15:16:32,159 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:110)

      15:16:32,164 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.jboss.as.quickstarts.servlet.HelloWorldMDBServletClient.doGet(HelloWorldMDBServletClient.java:82)

      15:16:32,165 ERROR [stderr] (http-/127.0.0.1:8080-1)    at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

      15:16:32,167 ERROR [stderr] (http-/127.0.0.1:8080-1)    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

      15:16:32,169 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:295)

      15:16:32,172 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:214)

      15:16:32,174 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)

      15:16:32,176 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:149)

      15:16:32,179 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:169)

      15:16:32,181 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:145)

      15:16:32,183 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:97)

      15:16:32,186 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:102)

      15:16:32,189 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:336)

      15:16:32,191 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)

      15:16:32,194 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:653)

      15:16:32,197 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:920)

      15:16:32,198 ERROR [stderr] (http-/127.0.0.1:8080-1)    at java.lang.Thread.run(Thread.java:745)

      15:16:32,199 ERROR [stderr] (http-/127.0.0.1:8080-1) Caused by: HornetQConnectionTimedOutException[errorType=CONNECTION_TIMEDOUT message=HQ119012: Timed out waiting to receive initial broadcast from cluster]

      15:16:32,201 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:843)

      15:16:32,204 ERROR [stderr] (http-/127.0.0.1:8080-1)    at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:672)

      15:16:32,206 ERROR [stderr] (http-/127.0.0.1:8080-1)    ... 18 more

       

      Does anyone have any ideas or suggestions on what I could try?  It seems like my JBoss EAP 6.2 cannot talk to the cluster, but not sure why.  I checked the address and port and it all looks to be correct.

       

      Thanks,

       

      Philip

        • 1. Re: JBoss EAP 6.2 communication with HornetQ 2.4.0 Cluster
          jbertram

          Can you attach logs from the 2 HornetQ servers which include the start-up process as well as the hornetq-configuration.xml from both?  It looks to me like you may be binding your HornetQ servers to "localhost" rather than a real network interface.

          • 2. Re: JBoss EAP 6.2 communication with HornetQ 2.4.0 Cluster
            ptenn10

            Hi Justin,

             

            Thank you so much for your reply.  I have attached my hornetq-configuration and hornetq.log files (I got a clean log file with just the start-up process)
            captured in it.

             

            I had to attach it to the original post since I could not find a way to attach files to a reply.

             

            Thanks,

             

            Philip

            • 3. Re: JBoss EAP 6.2 communication with HornetQ 2.4.0 Cluster
              jbertram

              The log contains this:

              09:56:22,597 INFO  [org.hornetq.core.server] HQ221020: Started Netty Acceptor version 4.0.13.Final localhost:5445

              09:56:22,608 INFO  [org.hornetq.core.server] HQ221020: Started Netty Acceptor version 4.0.13.Final localhost:5455

               

              If your server is binding to localhost then only clients on that same server can connect to it.  In other words, no remote clients can connect.  As far as I can tell the cluster bridge you see forming is the node connecting to itself.

               

              Try binding your HornetQ servers to a real network interface that can been seen by remote clients.