1 Reply Latest reply on Aug 17, 2013 6:37 PM by Andy Taylor

    HornetQ cluster loose half of messages after kill -9 of node

    Gregory Androsov Newbie

      Hello! I use Jboss EAP 6.1 and HornetQ 2.3.1 (default version distributed with jboss). I have troubles absolutely identity with this one https://issues.jboss.org/browse/HORNETQ-520

      Any suggestions? My code is bellow.

       

      There is my client-code

       

      package my.company;
      
      
      import java.util.HashMap;
      import java.util.Map;
      
      
      import javax.jms.Connection;
      import javax.jms.ConnectionFactory;
      import javax.jms.MessageProducer;
      import javax.jms.Queue;
      import javax.jms.Session;
      import javax.jms.TextMessage;
      
      
      import org.hornetq.api.core.TransportConfiguration;
      import org.hornetq.api.jms.HornetQJMSClient;
      import org.hornetq.api.jms.JMSFactoryType;
      import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
      import org.hornetq.core.remoting.impl.netty.TransportConstants;
      import org.hornetq.jms.client.HornetQQueue;
      
      
      public class MyHQClient {
      
      
                public static void main(String[] args) throws Exception {
                          final Queue queue = new HornetQQueue("PSIServiceQueue");
                          Map<String, Object> connectionParams = new HashMap<String, Object>();
                          connectionParams.put(TransportConstants.HOST_PROP_NAME,
                                              "192.168.100.97");
                          connectionParams.put(TransportConstants.PORT_PROP_NAME, 5445);
                          TransportConfiguration transportConfiguration = new TransportConfiguration(
                                              NettyConnectorFactory.class.getName(), connectionParams);
      
      
                          ConnectionFactory cf = (ConnectionFactory) HornetQJMSClient
                                              .createConnectionFactoryWithoutHA(JMSFactoryType.CF,
                                                                  transportConfiguration);
      
      
                          // JBoss requires passwords to have at least one numeric and
                          // non-alpha character
                          final Connection connection = cf.createConnection("hornetq",
                                              "HornetQ123!");
      
      
                          connection.start();
      
      
                          final Session session = connection.createSession(false,
                                              Session.AUTO_ACKNOWLEDGE);
      
      
                          MessageProducer queueProducer = session.createProducer(queue);
      
      
                          for (int i = 0; i < 10; i++) {
                                    TextMessage message = session.createTextMessage("Hello hornetq!"
                                                        + i);
                                    queueProducer.send(message);
                          }
                          connection.close();
      
      
                }
      }
      
      

       

      Also I have exceptions if I use 2 transport configuration and one of nodes fails:

       

       

      Exception in thread "main" javax.jms.JMSException: Failed to create session factory

                at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:587)

                at org.hornetq.jms.client.HornetQConnectionFactory.createConnection(HornetQConnectionFactory.java:107)

                at my.company.MyHQClient.main(MyHQClient.java:44)

      Caused by: HornetQException[errorType=NOT_CONNECTED message=HQ119007: Cannot connect to server(s). Tried with all available servers.]

                at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:852)

                at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:583)

                ... 2 more

       

       

      Map<String, Object> connectionParams = new HashMap<String, Object>();
                          connectionParams.put(TransportConstants.HOST_PROP_NAME,
                                              "192.168.100.97");
                          connectionParams.put(TransportConstants.PORT_PROP_NAME, 5445);
                          TransportConfiguration transportConfiguration = new TransportConfiguration(
                                              NettyConnectorFactory.class.getName(), connectionParams);
      
      
                          Map<String, Object> connectionParams2 = new HashMap<String, Object>();
                          connectionParams.put(TransportConstants.HOST_PROP_NAME,
                                              "192.168.100.99");
                          connectionParams.put(TransportConstants.PORT_PROP_NAME, 5445);
                          TransportConfiguration transportConfiguration2 = new TransportConfiguration(
                                              NettyConnectorFactory.class.getName(), connectionParams2);
      
      
                          ConnectionFactory cf = (ConnectionFactory) HornetQJMSClient
                                              .createConnectionFactoryWithoutHA(JMSFactoryType.CF,
                                                                  transportConfiguration, transportConfiguration2);