8 Replies Latest reply on Jun 20, 2011 2:28 AM by S ks

    Keeping connection alive by pinging the server

    S ks Newbie

      Hi ,

       

      Is there a way possible that i can send ping packets to hornetq server from the client so that connection is alive.

      I have set connectionTTL to 20 mins. But  i want to make sure that the even if client is not doing any picking of messages from the queue, it still should be alive way beyond 20 mins.

       

      If i set the connectionTTL to a large value , if the client crashes , and i try to reconnect to the server with the same clientID,  it throws an Exception saying durable subscription is still there. So ill have to restart the server too. So i want to set connectionTTL to a smaller value of 20 mins. but still want connection and durable subscription to be alive way beyound that , incase there is no activity from client(By activity i mean picking up the messages from the queue).

      Can i keep sending some kind of packet so that the my durable subscription connection is alive and session is maintained ?.

       

      Is it possible for me to recover the old session when i try to reconnect ?

       

      We are facing this issue in production ? Can i get some help in this regards.

       

       

      -rahul

        • 1. Re: Keeping connection alive by pinging the server
          Clebert Suconic Master

          You should probably try a smaller timeout.

           

          Or you could use management to kill the client.

           

          We can't let you reconnect to the same session through JMS as JMS doesn't let you have two connections with the same IDs (I assume you are using topics hence you need that).

           

           

          If you were using core-api, you would just be able to connect to the same core-queue without any issues.

          • 2. Re: Keeping connection alive by pinging the server
            S ks Newbie

            Thank you for your valuable inputs.

             

            If i have a JMS topic like below in hornetq-jms.xml

             

            <topic name="BillableAggregatedEvents">
                <entry name="/topic/BillableAggregatedEvents"/>
            </topic>

             

            Does this topic gets converted to core queue. of the type "jms.topic.BillableAggregatedEvents" ?

             

            The reason iam asking this is primarily on the consumer side we want to use Hornetq core , and on the producer side we have JMS producer.

            Which sends message on the JMS topic.

            So is it possible that a queue which is populated by the JMS producer is being consumed by Hornetq consumer ?

            • 3. Re: Keeping connection alive by pinging the server
              S ks Newbie

              I have create a JMS Topic of the form

               


              <topic name="BillableAggregatedEvents">
                  <entry name="/topic/BillableAggregatedEvents"/>

              </topic>

              In JConsole i can see that under Queue=>Core=> a queue is formed by the name "jms.topic.BillableAggregatedEvents".

               

              I created a ClientConsuer to connect to this queue , but though it connects but when JMSProducer is sending message to the topic, HornetqClient ClientConsumer is not recieving anything.

               

              Does this means, that If JMSProducer publishes on a topic ,  ClientConsumer cant consume those messages?

              It means eithere both Producer and COnsumer should be either ClientProducer and ClientConsumer or both should be JMSProducer and JMSconsumer ?

               

              Any help is deeply appreciated.

              • 4. Re: Keeping connection alive by pinging the server
                Clebert Suconic Master

                Yes, the subscription will be a core-queue. I can't remember the rule to compose the name now. You can probably find it easily on the JMX console. Let me know if you can't find it then I will figure out.

                • 5. Re: Keeping connection alive by pinging the server
                  S ks Newbie

                  Iam not able to figure out for which part you have said Yes.

                   

                  I have 2 questions primarily.

                   

                  1 . If JMSProducer publishes on a topic(Producer side implementation is JMS based ) ,  Can ClientConsumer  consume those messages , using the queue name?Because from JMX console i can see that all the JMS topics get converted to queuenames.

                   

                  2 . If 1 is false , It means either both Producer and COnsumer should be either ClientProducer and ClientConsumer or both should be JMSProducer and JMSconsumer ?

                  • 6. Re: Keeping connection alive by pinging the server
                    S ks Newbie

                    I looked at the JMX console.

                     

                    MBeanInfo for this core queue is : org.hornetq:module=Core,type=Queue,address="jms.topic.BillableAggregatedEvents",name="jms.topic.BillableAggregatedEvents"

                     

                    Iam using the core queue name as "jms.topic.BillableAggregatedEvents" (without double quotes) for the subcription , But when ClientConsumer is listening to this particular topic , we dont get any messages.

                     

                    Remember Producer is sending jms's MapMessages , On the consumer side we are recieveing ClientMessage and trying to use getStringProperty method to retrieve the object.

                    The above scenario is not working at all

                    • 7. Re: Keeping connection alive by pinging the server
                      Clebert Suconic Master

                      BTW: if you just want to use core-api on receiving a subscriber, you don't need to follow any standards to define the queue name.

                       

                      the only thing you need is to create a Queue on the Address for the topic. That way:

                       

                       

                      createQueue("jms.topic.TopicName", "my-queue_name");

                       

                      That way any message sent to the topic will be received on my-queue_name.

                       

                       

                      When you consume, you have to do createconsumer("my-queue_name");

                       

                       

                      Anyway, the name of the queue for a durable subscription is seen at HornetQDestination.

                      createQueueNameForDurableSubscription(final String clientID, final String subscriptionName)

                      • 8. Re: Keeping connection alive by pinging the server
                        S ks Newbie

                        What about the messages . The Producer is sending the MapMessages but on the consumer side we are accepting the ClientMessages.

                        Is there a conversion which is possible?

                         

                        thank you for ur inputs.