5 Replies Latest reply on Aug 1, 2008 3:16 AM by timfox

    How to send messages to a remote clustered queue (using HAJN

    theoverlord

      In trying to figure out how to send a message to a REMOTE clustered queue using HAJNDI from a JBoss AS (with no queue on it).

      So this is the setup:

      JBass AS (machine1) is sending a message to a clustered queue on (machine2 and machine 3).

      The clustered queues reside on machine2 and machine3 but not on machine1.

      machine2 and machine3 are part of the same partition cluster.

      machine1 is NOT part of the same cluster as machine2/machine3.


      So from machine1, i tried this:


      Hashtable properties = new Hashtable();
      properties.put("java.naming.provider.url", "machine2:1100, machine3:1100");
      properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
      properties.put("java.naming.factory.url.pkgs", "jboss.naming:org.jnp.interfaces");
      Context context = new InitialContext(properties);
      


      I tried to get the managed connection factory of the remote cluster but I couldn't find it using this code:

      // Thhis failed to find anything
      context.lookup("java:/JmsXA")
      


      I also need to lookup the remote queue and again I couldn't find anything
      // This failed
      context.lookup("queue/MyQueue");
      


      I'm totally confused.

      How do I do this?



        • 1. Re: How to send messages to a remote clustered queue (using
          ataylor

          You could start by having a look at the clustered examples shipped with JBM. Also the user doc is a good place to start.

          • 2. Re: How to send messages to a remote clustered queue (using
            theoverlord

            I took a look at the examples but I'm still confused.

            I see in the examples/distributed-queue example how it gets the connection factory from the initial context (DistributedQueueExample.java)

             ic = new InitialContext();
             cf = (ConnectionFactory)ic.lookup("/ClusteredConnectionFactory");
            



            That is not going to work with me since there is no ClusteredConnectionFactory on machine1 from where I'm trying to send the messages from. This example assumes that the sender is residing in the same AS as the queue it self which is not the case for me.

            Please help me.


            • 3. Re: How to send messages to a remote clustered queue (using
              ataylor

               


              That is not going to work with me since there is no ClusteredConnectionFactory on machine1 from where I'm trying to send the messages from. This example assumes that the sender is residing in the same AS as the queue it self which is not the case for me.


              You look up the connection factory via one of the nodes in the cluster. also all nodes should have the same connection factories deployed

              • 4. Re: How to send messages to a remote clustered queue (using
                theoverlord

                So i believe I should have been looking up the ClusteredConnectionFactory using normal JNDI instead of HAJNDI. Something like this I assume:

                Hashtable properties = new Hashtable();
                properties.put(Context.PROVIDER_URL, "machine2:1099, machine3:1099");
                ...
                ctx = new InitialContext(properties);
                
                // Connection factory
                ctx.lookup("/ClusteredConnectionFactory);
                
                // Lookup remote queue
                ctx.lookup("queue/MyQueue");
                


                Another question I have is would a connection obtained this way be container managed (pooled, etc) or would you have to take care of managing the connection.

                • 5. Re: How to send messages to a remote clustered queue (using
                  timfox

                  You can use either normal or HA JNDI it's up to you.

                  I'd recommend a book/tutorial on JNDI.