8 Replies Latest reply on Jul 17, 2013 4:06 AM by poonamkamboj

    JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA  problem

    poonamkamboj

      We are trying to do clustering of embedded hornetQ 2.3.1 of JBOSS EAP 6.1 . Clustering is done using multicast. We are currently running Live -Backup Configuration.

       

       

      Setup:

      • 2 EAP 6.1 running with standalone-full-ha.xml, 1 is live server and another is configured as backup for HornetQ
      • a sepearate EAP 6.1 is having web apllication deployed which connects to hornetq using remoteConnectionFactory.

       

      In our program,

      • Lookup the JNDI entires for RemoteConnectionFactory. (all JNDI entires and intial context is setup once in static block of program)
      • Connects to HornetQ, creates connection and session
      • Send and recieve message
      • close  session and  connection.

       

      Observations:

      • The above steps works fine as long as live server is up.
      • once live server is down, backup server takes up.
      • however new messages are not sent to hornetQ, we see the error on EAP console "Failed to connect to any of the live server "remote://live-server-ip:live-server-port" , where it still tries to connect to live server , not backup.

       

      Expected:

      • Program should be able to connect to backup server automatically and send/receive messages.

       

       

      Please find the attached configuration files of backup and live server as well.

       

      Please help.

        • 1. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA  problem
          ataylor

          how is your client configured to reconnect

          • 2. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA  problem
            poonamkamboj

            client is not reconnecting , only JNDI is configured for HA. Client tries connects to only live server URL every time (since this is the providerURL loaded intiially only once and used for initial context lookup)

            • 3. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA  problem
              ataylor

              client is not reconnecting , only JNDI is configured for HA. Client tries connects to only live server URL every time (since this is the providerURL loaded intiially only once and used for initial context lookup)

              I'm a bit confused as to what your issue is then, you said the client was not reconnecting?

              • 4. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA  problem
                poonamkamboj

                client connects fine to live server, but once live server is down, client program (in web application) doesn't automatically switch to Backup server, (as i read in one of the hornetq forums if ConnectionFactory is configured for HA, clients will be able to automatically connect to backup server once live server is down)

                • 5. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA  problem
                  ataylor

                  client connects fine to live server, but once live server is down, client program (in web application) doesn't automatically switch to Backup server, (as i read in one of the hornetq forums if ConnectionFactory is configured for HA, clients will be able to automatically connect to backup server once live server is down)

                  Thats what i was asking, how is your client configured, i.e. how is it connecting, code etc?

                  • 6. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA  problem
                    poonamkamboj

                    JNDI entires are loaded once as follows in static block

                    =========================================================================================================================================================

                    static{

                              InputStream jndiStream =

                                   MessageQueue.class.getClassLoader().getResourceAsStream("jndi.properties");

                              try {

                                   jndiProperties.load(jndiStream);

                             } catch (IOException e1) {

                                   e1.printStackTrace();

                             }

                              Properties initialContextProperties = new Properties();

                             if (!isNullOrEmpty(jndiProperties.getProperty("initialContextFactory"))){

                                   initialContextProperties.put(Context.INITIAL_CONTEXT_FACTORY,

                                             jndiProperties.getProperty("initialContextFactory"));

                             }

                             if (!isNullOrEmpty(jndiProperties.getProperty("urlPkgPrefixes"))){

                                   initialContextProperties.put(Context.URL_PKG_PREFIXES,

                                             jndiProperties.getProperty("urlPkgPrefixes"));

                             }

                             if (!isNullOrEmpty(jndiProperties.getProperty("brokerURL"))){

                                   initialContextProperties.put(Context.PROVIDER_URL,

                                             jndiProperties.getProperty("brokerURL"));

                             }

                             initialContextProperties.put(Context.SECURITY_PRINCIPAL,

                                       jndiProperties.getProperty("userName"));

                             initialContextProperties.put(Context.SECURITY_CREDENTIALS,

                                       jndiProperties.getProperty("password"));

                           try {

                                   initialContext = new InitialContext(initialContextProperties);

                     

                                   System.out.println(" Initial Context Factory got Setup ");

                                   _queueConnectionFactory = (QueueConnectionFactory) initialContext.lookup(jndiProperties.getProperty("connectionFactory"));

                     

                             }

                             catch (NamingException e) {

                                    e.printStackTrace();

                             }catch (javax.jms.JMSException jmse)

                             {

                                   jmse.printStackTrace();

                             }

                          }

                    =========================================================================================================================================================

                    connect method  (called everytime for connection)

                    =========================================================================================================================================================

                    _connect = _queueConnectionFactory.createQueueConnection(jndiProperties.getProperty("userName"),jndiProperties.getProperty("password"));

                    if(_connect !=null)

                                   {

                                   _connect.setExceptionListener(_exceptionListener);

                                   _session = _connect.createQueueSession(true, javax.jms.Session.CLIENT_ACKNOWLEDGE);

                                    System.out.println("===QueueSession got created===");

                                   }

                                   else

                                   {

                                       throw new NamingException();

                                   }

                    =========================================================================================================================================================

                    sends the message

                    =========================================================================================================================================================

                    receives reply

                    =========================================================================================================================================================

                    close the session and connection

                    So above steps happens for each message except JNDI lookup entries.

                    • 7. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA  problem
                      ataylor

                      well your error looks like a jndi error not a HornetQ, i.e. "Failed to connect to any of the live server "remote://live-server-ip:live-server-port".

                       

                      Also, you are creating a new connction every time you send a message which is an anti pattern, connections should be long lived. This also means that it will use the details of the connection facory you looked up whjen it tries to connect.

                      • 8. Re: JBOSS EAP 6.1 embedded HornetQ 2.3.1 clustering, ConnectionFactory HA  problem
                        poonamkamboj

                        Thanks Andy for the clarification.

                         

                        We started with putting 2 provider URLs (live server, backup server), then producers/consumers were able to switch to backup serve when live server is down.