7 Replies Latest reply on Oct 1, 2014 9:52 AM by Harley Blumenfeld

    Stomp Client 1.5.4 error creating subscription to topic on JBoss HornetQ (Jboss 6.4.2 GA)

    Harley Blumenfeld Newbie

      I apologize for posting a very similar issue to this one(Error creating consumer with STOMP), but it appears I am having a similar problem although with different symptoms.


      Maybe I am doing something dumb, but using a simple example I cannot seem to get a topic subscription working using the Apache.NMS.Stomp version 1.5.4 (http://activemq.apache.org/nms/apachenmsstomp-v154.html).

       

       

      I am compiling the Stomp source code and project under .Net 4.0. I have created a console application in the Apache.NMS.Stomp solution. My program fails when it attempts to create a subscription to the topic. The same example works fine with the 1.5.3 version of the DLL so this seems like it could be a bug.

      I do not see any error messages on the server side.

       

      Here is the result of my simple program:

      About to connect to stomp:tcp://myjboss:61613

      Using destination: topic://jms.topic.test.topic

      Connection Error: : Error creating subscription IDcSTHBLUMENF-50514-635475847768724525-1:0c1:1

       

       

      Connection Error:

      Error: : Error creating subscription IDcSTHBLUMENF-50514-635475847768724525-1:0c1:1

       

       

      Error:  at Apache.NMS.Stomp.Connection.SyncRequest(Command command, TimeSpan requestTimeout) in C:\dev\Apache.NMS.Stomp\source\branches\1.5.4\src\main\csharp\Connection.cs:line 525

        at Apache.NMS.Stomp.Connection.SyncRequest(Command command) in C:\dev\Apache.NMS.Stomp\source\branches\1.5.4\src\main\csharp\Connection.cs:line 505

        at Apache.NMS.Stomp.Session.CreateConsumer(IDestination destination, String selector, Boolean noLocal) in C:\dev\Apache.NMS.Stomp\source\branches\1.5.4\src\main\csharp\Session.cs:line 425

        at Apache.NMS.Stomp.Session.CreateConsumer(IDestination destination) in C:\dev\Apache.NMS.Stomp\source\branches\1.5.4\src\main\csharp\Session.cs:line 379

        at TopicSubscriberTest.Program.Main(String[] args) in C:\dev\Apache.NMS.Stomp\source\branches\1.5.4\TopicSubscribeTest\Program.cs:line 31

       

      Here is the code:

      class Program
      {                
           private static void Main(string[] args)
           {
                try
                {
                     var connecturi = new Uri("stomp:tcp://myjboss:61613");
                     Console.WriteLine("About to connect to " + connecturi);
                     IConnectionFactory factory = new NMSConnectionFactory(connecturi);
      
                     using (IConnection connection = factory.CreateConnection("testuser", "test"))               {
                          connection.ExceptionListener += new ExceptionListener(OnConnectionException);
                          connection.Start();
      
                          using (ISession session = connection.CreateSession())
                          {                        
                               connection.Start();                        
                               IDestination destination = SessionUtil.GetDestination(session,"topic://jms.topic.test.topic");
                               Console.WriteLine("Using destination: " + destination);
                               using (IMessageConsumer consumer = session.CreateConsumer(destination))
                               {                                                        
                                    consumer.Listener += OnMessage;
                                    while (true)
                                    {
                                         Thread.Sleep(5000);
                                         Console.WriteLine(".");
                                    }
                               }
                          }
                     }
                }
                catch (Exception e)
                {
                     Console.WriteLine("Error:" + e.Message);
                     Console.WriteLine("Error:" + e.StackTrace);
                     Console.ReadLine();
                }
           }
      
           private static void OnConnectionException(Exception e)
           {
                Console.WriteLine("Connection Error:" + e.Message);
                Console.WriteLine("Connection Error:" + e.StackTrace);
           }
      
           protected static void OnMessage(IMessage receivedMsg)
           {
                var message = receivedMsg as ITextMessage;
                Console.WriteLine(message.Text);
           }
      }