1 Reply Latest reply on Jul 8, 2013 10:23 AM by erasmomarciano

    ClusterJMS Jboss7

    erasmomarciano

      Hi

      I have this scenary

       

      1) JBOSS A

        --> ./standalone.sh --server-config=standalone-full_jms_cluster.xml

       

      2) JBOSS B

      --> ./standalone2.sh --server-config=standalone-full_jms_cluster.xml

       

      Both Jboss nodes started without  errors.

       

      The cluster is correctly configured, as following:

       

       

      5:17:21,878 INFO  [org.hornetq.core.server.cluster.impl.BridgeImpl] (Thread-9 (HornetQ-server-HornetQServerImpl::serverUUID=7b3d2f3f-e7cf-11e2-a0d4-31e7b898d520-23822211)) Bridge ClusterConnectionBridge@1162ab9 [name=sf.my-cluster.81d3e434-e7cf-11e2-ac8a-29b3614b96a4, queue=QueueImpl[name=sf.my-cluster.81d3e434-e7cf-11e2-ac8a-29b3614b96a4, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=7b3d2f3f-e7cf-11e2-a0d4-31e7b898d520]]@4eda4a targetConnector=ServerLocatorImpl (identity=(Cluster-connection-bridge::ClusterConnectionBridge@1162ab9 [name=sf.my-cluster.81d3e434-e7cf-11e2-ac8a-29b3614b96a4, queue=QueueImpl[name=sf.my-cluster.81d3e434-e7cf-11e2-ac8a-29b3614b96a4, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=7b3d2f3f-e7cf-11e2-a0d4-31e7b898d520]]@4eda4a targetConnector=ServerLocatorImpl [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5446&host=localhost-localdomain], discoveryGroupConfiguration=null]]::ClusterConnectionImpl@9874503[nodeUUID=7b3d2f3f-e7cf-11e2-a0d4-31e7b898d520, connector=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5445&host=localhost-localdomain, address=jms, server=HornetQServerImpl::serverUUID=7b3d2f3f-e7cf-11e2-a0d4-31e7b898d520])) [initialConnectors=[org-hornetq-core-remoting-impl-netty-NettyConnectorFactory?port=5446&host=localhost-localdomain], discoveryGroupConfiguration=null]] is connected

       

      I have an client  Jms(queue) that connects in this mode:

       

      private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";

          private static final String DEFAULT_DESTINATION = "jms/queue/test";

          private static final String DEFAULT_MESSAGE_COUNT = "1000";

          private static final String DEFAULT_USERNAME = "quickstartUser";

          private static final String DEFAULT_PASSWORD = "quickstartPassword";

          private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";

          private static final String PROVIDER_URL = "remote://localhost:4447";

       

      The queue messages are only delivered locally

       

      How can I send and receive messages on both nodes ?

       

      Is there a Cluster Vip, Common Port or something that i am missing?

       

      thank you

        • 1. Re: ClusterJMS Jboss7
          erasmomarciano

          attach my code

           

          public class HelloWorldJMSClient {

              private static final Logger log = Logger.getLogger(HelloWorldJMSClient.class.getName());

           

              // Set up all the default values

              private static final String DEFAULT_MESSAGE = "Hello, World inviato 1000 volte!";

              private static final String DEFAULT_CONNECTION_FACTORY = "jms/RemoteConnectionFactory";

              private static final String DEFAULT_DESTINATION = "jms/queue/test";

          //    private static final String DEFAULT_DESTINATION = "jms/topic/test";

              private static final String DEFAULT_MESSAGE_COUNT = "1000";

              private static final String DEFAULT_USERNAME = "quickstartUser";

              private static final String DEFAULT_PASSWORD = "quickstartPassword";

              private static final String INITIAL_CONTEXT_FACTORY = "org.jboss.naming.remote.client.InitialContextFactory";

          //    private static final String PROVIDER_URL = "remote://localhost:4447";

              private static final String PROVIDER_URL = "remote://231.7.7.7:9876";

           

              public static void main(String[] args) throws Exception {

           

                  ConnectionFactory connectionFactory = null;

                  Connection connection = null;

                  Session session = null;

                  MessageProducer producer = null;

                  MessageConsumer consumer = null;

                  Destination destination = null;

                  TextMessage message = null;

                  Context context = null;

           

                  try {

                      // Set up the context for the JNDI lookup

                      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.put(Context.SECURITY_PRINCIPAL, System.getProperty("username", DEFAULT_USERNAME));

                      env.put(Context.SECURITY_CREDENTIALS, System.getProperty("password", DEFAULT_PASSWORD));

                      context = new InitialContext(env);

           

                      // Perform the JNDI lookups

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

                      log.info("Attempting to acquire connection factory \"" + connectionFactoryString + "\"");

                      connectionFactory = (ConnectionFactory) context.lookup(connectionFactoryString);

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

           

                      String destinationString = System.getProperty("destination", DEFAULT_DESTINATION);

                      log.info("Attempting to acquire destination \"" + destinationString + "\"");

                      destination = (Destination) context.lookup(destinationString);

                      log.info("Found destination \"" + destinationString + "\" in JNDI");

           

                      // Create the JMS connection, session, producer, and consumer

                      connection = connectionFactory.createConnection(System.getProperty("username", DEFAULT_USERNAME), System.getProperty("password", DEFAULT_PASSWORD));

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

                      producer = session.createProducer(destination);

                      consumer = session.createConsumer(destination);

                      connection.start();

           

                      int count = Integer.parseInt(System.getProperty("message.count", DEFAULT_MESSAGE_COUNT));

                      String content = System.getProperty("message.content", DEFAULT_MESSAGE);

           

                      log.info("Sending " + count + " messages with content: " + content);

           

           

          ................