1 2 Previous Next 15 Replies Latest reply on Nov 1, 2013 5:38 AM by Christiaan van Tienhoven

    STOMP 1.1 problems with 2.3.0.Final

    Mitchell Ackerman Newbie

      Hi, we just upgraded from horneq 2.2.14 with stomp 1.0 to 2.3.0.Final using stomp 1.1, and are having issues with subscriptions to topics.  Stomp was working fine with the former versions. Basically we are not getting any messages as it appears that the subscription id is becoming corrupted.  In debugging the messages here is what we have found:

       

      CONNECT

      accept-version:1.0,1.1

      heart-beat:10000,30000

      host:10.2.62.57

      client-id:ID:CLSCHAEFER-DT-13041-635031774708309151-0:0

      login:guest

      passcode:guest

       

      CONNECTED

      version:1.1

      session:-139748640

      server:HornetQ/2.3.0.SNAPSHOT (colonizer, 123) HornetQ Messaging Engine

      heart-beat:30000,10000

       

       

      SUBSCRIBE

      id:ID\cCLSCHAEFER-DT-13041-635031774708309151-1\c0\c1\c1

      receipt:2

      destination:jms.topic.asyncEvents

      activemq.dispatchAsync:True

      transformation:jms-xml

      activemq.priority:0

      activemq.maximumPendingMessageLimit:0

      activemq.prefetchSize:32766

      ack:client

       

      RECEIPT

      receipt-id:2

       

      MESSAGE

      subscription:IDcCLSCHAEFER-DT-13041-635031774708309151-1\\c0c1\\c1

      message-id:23

      destination:jms.topic.asyncEvents

      expires:0

      redelivered:false

      priority:4

      timestamp:0

      http_content$type:application/json

      confId:KEEP_ALIVE

      __HQ_CID:3b7029d5-b417-11e2-b5bf-879f7fd33a6e

       

      If you look at the subscription id you will see that the escaped colons have been messed up, which appears to be occurring in the StompDecoder. As a result no messages match for the actual subscription id on the client and are therefore not processed.

       

      A temporary fix is to set the clientId on the client to some simple string, which does then not require decoding escaped characters.  We had to modify ApacheNMS to do that, as the attribute is not accessible, so is not a good long term solution.

       

      Mitchell

        • 1. Re: STOMP 1.1 problems with 2.3.0.Final
          Yong Hao Gao Master

          Hi,

           

          1) Do you use stomp 1.1 with HornetQ 2.2.14?

          2) Can you upload the test (if any) ?

           

          Thanks

          Howard

          • 2. Re: STOMP 1.1 problems with 2.3.0.Final
            Mitchell Ackerman Newbie

            with 2.2.14 we used Stomp 1.0.  with 2.3.0, ApacheNMS is defaulting to Stomp 1.1, so that is what we are now using.

             

            Unfortunately, we don't currently have a simple example that we can sent, though I would think that it would be pretty straightforward to make one using ApacheNMS and a hornetq topic. However, one of our team members is working on one, and we'll provide it when available.

             

            Mitchell

            • 3. Re: STOMP 1.1 problems with 2.3.0.Final
              Mitchell Ackerman Newbie

              I couldn't see how to insert an executable, so here is the source code:

               

              using System;

              using Apache.NMS;

               

               

              namespace StompClient

              {

                  class StompClient

                  {

                      static void Main(string[] args)

                      {

                          try

                          {

                              string StompUriFormat = "stomp:tcp://{0}:{1}";

                              string hostname = "localhost";

                              string port = "61613";

                              string topic = "asyncEvents";

                              string consumerId = null;

               

               

                              for (int i = 0; i < args.Length; i++) // Loop through array

                              {

                                  string argument = args[i];

                                  if (argument.Equals("-h"))

                                      hostname = args[i + 1];

                                  if (argument.Equals("-p"))

                                      port = args[i + 1];

                                  if (argument.Equals("-t"))

                                      topic = args[i + 1];

                                  if (argument.Equals("-c"))

                                      consumerId = args[i + 1];

                                  if (argument.Equals("-?"))

                                  {

                                      Console.WriteLine("StompClient -h <hostname> -p <port number> -t <topic> -c <consumerId>");

                                      return;

                                  }

                              }

               

               

                              string StompUri = string.Format(StompUriFormat, hostname, port);

               

               

                              Console.WriteLine("Attempting to connect to " + StompUri);

               

               

                              IConnectionFactory factory = new NMSConnectionFactory(new Uri(StompUri));

               

               

                              IConnection connection = factory.CreateConnection();

                              connection.AcknowledgementMode = AcknowledgementMode.AutoAcknowledge;

               

               

                              ISession session = connection.CreateSession();

               

               

                              IDestination destination = session.GetTopic(topic);

               

               

                              IMessageConsumer consumer = session.CreateConsumer(destination, null, consumerId);

                              Console.WriteLine(string.Format("Created consumer with topic {0} and consumerId {1}, waiting for messages", topic, consumerId == null ? "null" : consumerId));

               

               

                              connection.Start();

                              consumer.Listener += new MessageListener(OnMessage);

               

               

                              Console.WriteLine("Press <Enter> to exit program");

                              Console.ReadLine();

                              connection.Close();

                          }

                          catch (NMSException ex)

                          {

                              Console.WriteLine("Exception: " + ex.Message);

                              Console.WriteLine("Press <Enter> to exit program");

                              Console.ReadLine();

                          }

                      }

               

               

                      private static void OnMessage(IMessage message)

                      {

                          try

                          {

                              ITextMessage msg = (ITextMessage)message;

                              Console.WriteLine(DateTime.Now.ToString("HH:mm:ss")  + " - Message Received: " + msg.Text);

                          }

                          catch (Exception ex)

                          {

                              Console.WriteLine("Exception: " + ex.Message);

                          }

                      }

                  }

              }

              • 4. Re: STOMP 1.1 problems with 2.3.0.Final
                Yong Hao Gao Master

                Thanks. But I think it is important how you pass in the client-id header, can you give the actual value (hard-coded) of it in the source-code?

                • 5. Re: STOMP 1.1 problems with 2.3.0.Final
                  Mitchell Ackerman Newbie

                  The ApacheNMS code generates the clientId.  It is not normally a visible method.  Our workaround was to make it public and provide a simple string, with no characters that would result in escaped characters.

                  • 6. Re: STOMP 1.1 problems with 2.3.0.Final
                    Vijay Mudunuri Newbie

                    Hi Mitchell Ackerman,

                     

                    We are also trying to updrade from horneq 2.2.14 with stomp 1.0 to 2.3.0.Final using stomp 1.1 for replication. We are also using apache NMS and facing the same issues. But, I see that you have provided a turn around for the problem with subscription ids. I tried your solution by modifying the client library, but it did not made any difference. I am also passing a simple string. Can you please help me on this issue. Below I am also providing may sample code:

                     

                     

                     

                    string uri = "stomp:tcp://localhost:61613";

                    string topic = "topic://testTopic";

                    string queue = "queue://testQueue";

                    connectionFactory = new NMSConnectionFactory(uri);

                    connection = co nnectionFactory.CreateConnection("guest", "guest");

                    connection.ClientId = "SampleConsumer";

                    connection.Start();               

                    Session session = (Session)connection.CreateSession();

                    IDestination destination = SessionUtil.GetDestination(session, topic);

                    IMessageConsumer consumer = session.CreateConsumer(destination, null, "IDSampleClient");               

                    consumer.Listener += new MessageListener(onMessage);

                    session.Close();

                    connection.close();

                     

                     

                    regards,

                    Vijay

                    • 7. Re: STOMP 1.1 problems with 2.3.0.Final
                      Mitchell Ackerman Newbie

                      Vinjay, what we found to be the problem was that the subscriptionId was being mangled:

                       

                      id:ID\cCLSCHAEFER-DT-13041-635031774708309151-1\c0\c1\c1

                       

                      was becoming

                       

                      subscription:IDcCLSCHAEFER-DT-13041-635031774708309151-1\\c0c1\\c1

                       

                      Can you confirm that you are seeing the same symptom using wireshark (or other capture mechanism)? The key was that the id included characters that needed to be escaped, which wasn't happening properly, thus the mangling.  We provided our own id that did not include any such characters, which fixed the problem.

                      • 8. Re: STOMP 1.1 problems with 2.3.0.Final
                        Vijay Mudunuri Newbie

                        Hi Mitchell Ackerman,

                         

                        I checked the traffic to hornetQ using wireshark and here is the reponse:

                         

                        subscription:IDcASF-MSG-EXT-55184-635058511098154818-1\\c0c1\\c1

                        message-id:19

                        destination:jms.topic.testTopic

                        expires:0

                        redelivered:false

                        priority:5

                        timestamp:1370247237118

                        receipt:2

                        timestamp:1370247238080

                        NMSXDeliveryMode:true

                         

                        Producer Sending message!

                         

                        So I am also seeing the same symptom with hornetQ and apache nms. If you don't mind I have another question regarding the nms api. When I was using hornetQ 2.2.14 stanalone, I slightly modified the apache nms library to declare queues and topics as"jms.queue.ExampleQueue" instead of "/queue/ExampleQueue". Does your workaround also require these changes in addition to the subscriptionid ? And, does the entire subscriptionid should be replaced with a simple string or only the preceding characters (for example "ID\c" to "ID1") ? Also, it would be great if you provide a sample subscriptionid

                         

                        Regards,

                        vijay

                        • 9. Re: STOMP 1.1 problems with 2.3.0.Final
                          Mitchell Ackerman Newbie

                          Vijay, yes, we had to modify the library to change the queue and topic names as you describe.  We had to replace the whole subscription id with a 'simple' string, one not requiring escaped characters.  It looks like your subscription Id does have such characters "\\c0c1\\c1", so I would remove those.

                           

                          Unfortunately, I don't have access to the code at this time, but if you still need it let me know and i'll dig it up.

                           

                          Mitchell

                          • 10. Re: STOMP 1.1 problems with 2.3.0.Final
                            Vijay Mudunuri Newbie

                            Hi Mitchell,

                             

                            Thanks for the reply, I did passed a simple string for example "ASFMESSGTXT" and also changed the method "ToString()" in the class "ConsumerId.cs" to get rid of colons. I also printed out the subscriptionId of the client.

                             

                            connectionFactory = new NMSConnectionFactory(uri);

                            connection = connectionFactory.CreateConnection("guest", "guest");

                            connection.AcknowledgementMode = AcknowledgementMode.AutoAcknowledge;              

                            Session session = (Session)connection.CreateSession();

                            IDestination destination = SessionUtil.GetDestination(session, topic);               

                            session.SessionId.ConnectionId = "ASFMESSGTXT";

                            IMessageConsumer consumer = session.CreateConsumer(destination, null, "ASFMESSGTXT");              

                            MessageConsumer messgConsumer = (MessageConsumer)consumer;

                            connection.Start();

                            consumer.Listener += new MessageListener(onMessage);

                            Console.WriteLine(DateTime.Now + " - Subscribed to the topic: " + topic + "\n");

                            Console.WriteLine("SubscrptionId: " + messgConsumer.ConsumerId);

                             

                            The console printed out "SubscriptionId: ASFMESSGTXT11". So it did not has any escape characters. Also I recorded the message from wireshark

                             

                            CONNECTED

                            version:1.1

                            session:-1601281562

                            server:HornetQ/2.3.0.SNAPSHOT (colonizer, 123) HornetQ Messaging Engine

                            heart-beat:30000,10000

                             

                            MESSAGE

                            subscription:ASFMESSGTXT11

                            message-id:309

                            destination:jms.topic.testTopic

                            expires:0

                            redelivered:false

                            priority:5

                            timestamp:1370327406447

                            receipt:2

                            timestamp:1370327408292

                            NMSXDeliveryMode:true

                            Producer Sending message!

                             

                            If you see the message, it also has the same subscriptionId, but the client is not receiving any message and it keeps on waiting and sending the heartbeats.

                            Yes, it would be really great if you can provide a small code snippet regarding modifications you made to the library. Also, I am sending the session.cs file of the nms library which I modified. Please look at it if you have some time,

                            • 11. Re: STOMP 1.1 problems with 2.3.0.Final
                              Mitchell Ackerman Newbie

                              Appologies for the delay Vijay, I don't have access to the repo where the code resides, so had to ask...

                               

                              Anyway, I attached our session class.  Let me know if that helps.

                               

                              Mitchell

                              • 12. Re: STOMP 1.1 problems with 2.3.0.Final
                                Vijay Mudunuri Newbie

                                Hi Mitchell,

                                 

                                No need of appologies . It really worked like a charm. Thank you very much for the help.

                                 

                                Regards,

                                Vijay

                                • 13. Re: STOMP 1.1 problems with 2.3.0.Final
                                  karuna goyal Newbie

                                  Hi Mitchell,

                                  I am using HornetQ from C#. I have HornetQ 2.3.0 Final with STOMP 1.1. I am able to publish the messages using the attached code but consumer is not receiving the messages. I modified the source code for STOMP library for the queue naming issue. Can you please look into my code if you have little time? I have attached all consumer, producer and my configuration files.

                                  Thanks in advance

                                  Karuna Goyal

                                  
                                  
                                  • 14. Re: Re: STOMP 1.1 problems with 2.3.0.Final
                                    karuna goyal Newbie

                                    Hi Vijay,

                                    Is it possible for you to share a complete sample program in C# which talks to Hornetq to send and receive data? As I said in the above post, I am not able to make it work. I am able to publish the messages but not able to receive. I have attached my code and all the configuration files.

                                    Thanks in advance.


                                    Karuna

                                    1 2 Previous Next