8 Replies Latest reply on Oct 20, 2010 3:35 AM by Tim Fox

    HornetQ Core Client to a JMS Topic

    Adams Tan Newbie

      Hi all,

       

      I'm a little confused here. If I want to create a HornetQ core client (standalone java app) to listen to messages published via JNDI (JMS topic running on JBoss AS5), is that possible? If so, how do I link it up to the ClientSessionFactory?

       

      All the examples I have seen so far is via the standalone CORE server.

       

      Thanks in advance.

      Ads

        • 1. Re: HornetQ Core Client to a JMS Topic
          Clebert Suconic Master

          With core api, a subscription is just a queue.

           

          You could make the relation: JMS Topic -> Address

           

          Subscription -> Queue

           

          The queuename will be a combination of the connectionID + subscription name.

           

           

          This has been asked before on the forums btw.

          • 2. Re: HornetQ Core Client to a JMS Topic
            Adams Tan Newbie

            Clebert Suconic wrote:

             

            With core api, a subscription is just a queue.

             

            You could make the relation: JMS Topic -> Address

             

            Subscription -> Queue

             

            The queuename will be a combination of the connectionID + subscription name.

            Yeap, I noticed this from the documentation...

             

            What I wanted to clarify (at least from what I saw from the examples) is, when using the core api, could I use the core api to consume messages directly off a jms topic (or queue), eg. via JNDI.

             

            Or do i have to connect to some sort of CORE api queue on a HornetQ standalone server, and use a JMS bridge to link up the 2.

            • 3. Re: HornetQ Core Client to a JMS Topic
              Clebert Suconic Master

              the JMS Layer is using the core API. You can just use the core API do the Queue associated with the subscription. pretty simple!

              • 4. Re: HornetQ Core Client to a JMS Topic
                Adams Tan Newbie

                Clebert Suconic wrote:

                 

                the JMS Layer is using the core API. You can just use the core API do the Queue associated with the subscription. pretty simple!

                Sorry.. i'm a bit slow here.. do you have any examples of using CORE to subscribe to a JMS queue via JNDI?

                • 5. Re: HornetQ Core Client to a JMS Topic
                  Clebert Suconic Master

                  ClientSession session = ....createSession....

                  session.createQueue(jms.topic.topicName, "my queue name");

                   

                  ^^^ that will be your subscription already

                   

                   

                  Concumser cons = createconsumer("my queue name");

                  • 6. Re: HornetQ Core Client to a JMS Topic
                    Adams Tan Newbie

                    This is what i'm trying to achieve:

                     

                    ClientSessionFactory sf = HornetQClient.createClienSessionFactory("localhost", 1099);
                    ClientSession session = null;
                    try {
                        session = sf.createSession();
                        String addName = "/queue/TestQueue01"; //this is my JMS Queue name exposed to other modules
                        String queueName = "queue.qq";
                       
                        ...

                    ClientSessionFactory sf = HornetQClient.createClienSessionFactory("localhost", 1099);

                    ClientSession session = null;


                    try {

                        session = sf.createSession();

                        String addName = "/queue/TestQueue01"; //this is my JMS Queue name exposed to other modules

                        String queueName = "queue.qq";

                       

                        ...

                     

                    When I run, i get an error:

                    SEVERE: Failed to create discovery group socket

                    java.net.SocketException: Not a multicast address

                     

                     

                    Any ideas?

                     

                    Thanks

                    • 7. Re: HornetQ Core Client to a JMS Topic
                      Clebert Suconic Master

                      you're getting a more basic error to even connect to the server.

                       

                      I suggest you looking at the examples and documentation as to how to connect the server.

                      • 8. Re: HornetQ Core Client to a JMS Topic
                        Tim Fox Master

                        Adams Tan wrote:

                         


                        When I run, i get an error:

                        SEVERE: Failed to create discovery group socket

                        java.net.SocketException: Not a multicast address

                         

                         

                        Any ideas?

                         

                        Thanks

                        Sorry, couldn't resist chipping in on some low hanging fruit...

                         

                        The error message says it all, the address you're using for discovery is not a multicast address.

                         

                        What is, and what is not a multicast address you can find out from a google