1 2 Previous Next 19 Replies Latest reply on Sep 30, 2014 11:45 AM by Yong Hao Gao

    Error creating consumer with STOMP

    Yair Ogen Expert

      I hope this is the right place for STOMP support.

       

      I am able to connect to my server using STOMP. Using a .NET client with this code"

       

       IConnectionFactory factory = new NMSConnectionFactory(new Uri("stomp:tcp://10.45.37.202:61613"));
                   
                   IConnection connection = factory.CreateConnection();
                   
                   ISession session = connection.CreateSession();
                   
                   
                   ITopic destination = session.GetTopic("myExample");
                   
                   IMessageConsumer consumer = session.CreateDurableConsumer(destination,"stompConsumer1234","",true);
                   
                   connection.Start();
      

       

      running it it fails on:

       

      Apache.NMS.Stomp.BrokerException:  : HQ339016: Error creating subscription

       

      any ideas?

        • 1. Re: Error creating consumer with STOMP
          Yong Hao Gao Master

          may be you need to add "jms.topic." to your topic like "jms.topic.myExample"?

          • 2. Re: Re: Error creating consumer with STOMP
            Yair Ogen Expert

            something like this?

             

             IMessageConsumer consumer = session.CreateDurableConsumer(destination,"jms.topic.stompConsumer1234","",true);
            

             

            didn't work.

            • 3. Re: Re: Error creating consumer with STOMP
              Yong Hao Gao Master

              I'm thinking of trying this:

               

              ITopic destination = session.GetTopic("jms.topic.myExample");

              • 5. Re: Re: Error creating consumer with STOMP
                Yong Hao Gao Master

                do you mind posting your hornetq topic configuration?

                • 6. Re: Re: Error creating consumer with STOMP
                  Yair Ogen Expert

                  no configuration

                  I created the topic off line using core API

                  • 7. Re: Re: Error creating consumer with STOMP
                    Yong Hao Gao Master

                    Durable subs require a client-id, I don't know how to set it using .Net. However I think you need to check this just in case you didn't set it.

                    • 8. Re: Re: Error creating consumer with STOMP
                      Yair Ogen Expert

                      Added this which didn't help:

                       

                      connection.ClientId="uniqueClient";

                       

                      Also - the same error occurs whilst creating a regular consumer

                      • 9. Re: Re: Error creating consumer with STOMP
                        Yong Hao Gao Master

                        did you see any error message in the server's log file?

                        • 10. Re: Re: Error creating consumer with STOMP
                          Yair Ogen Expert

                          11:08:55,199 ERROR [org.hornetq.core.server] HQ224006: Invalid filter:  AND __HQ_CID <> '-1274344503': org.hornetq.core.filter.impl.ParseException: Encountered " "AND" "AND "" at line 1, column 2.

                          Was expecting one of:

                              "TRUE" ...

                              "FALSE" ...

                              "NOT" ...

                              "(" ...

                              "-" ...

                              "+" ...

                              <INTEGER_LITERAL> ...

                              <FLOATING_POINT_LITERAL> ...

                              <SIMPLE_STRING> ...

                              <IDENTIFIER> ...

                           

                           

                                  at org.hornetq.core.filter.impl.FilterParser.generateParseException(FilterParser.java:1482) [hornetq-core-client-2.4.1.Final.jar:]

                                  at org.hornetq.core.filter.impl.FilterParser.jj_consume_token(FilterParser.java:1364) [hornetq-core-client-2.4.1.Final.jar:]

                                  at org.hornetq.core.filter.impl.FilterParser.selectorFactor(FilterParser.java:181) [hornetq-core-client-2.4.1.Final.jar:]

                                  at org.hornetq.core.filter.impl.FilterParser.selectorTerm(FilterParser.java:139) [hornetq-core-client-2.4.1.Final.jar:]

                                  at org.hornetq.core.filter.impl.FilterParser.selectorExpression(FilterParser.java:117) [hornetq-core-client-2.4.1.Final.jar:]

                                  at org.hornetq.core.filter.impl.FilterParser.expression(FilterParser.java:108) [hornetq-core-client-2.4.1.Final.jar:]

                                  at org.hornetq.core.filter.impl.FilterParser.parse(FilterParser.java:61) [hornetq-core-client-2.4.1.Final.jar:]

                                  at org.hornetq.core.filter.impl.FilterParser.parse(FilterParser.java:41) [hornetq-core-client-2.4.1.Final.jar:]

                                  at org.hornetq.core.filter.impl.FilterImpl.createFilter(FilterImpl.java:97) [hornetq-server.jar:]

                                  at org.hornetq.core.server.impl.HornetQServerImpl.createQueue(HornetQServerImpl.java:1902) [hornetq-server.jar:]

                                  at org.hornetq.core.server.impl.HornetQServerImpl.createQueue(HornetQServerImpl.java:1116) [hornetq-server.jar:]

                                  at org.hornetq.core.server.impl.ServerSessionImpl.createQueue(ServerSessionImpl.java:439) [hornetq-server.jar:]

                                  at org.hornetq.core.protocol.stomp.StompSession.addSubscription(StompSession.java:289) [hornetq-stomp-protocol.jar:]

                                  at org.hornetq.core.protocol.stomp.StompProtocolManager.createSubscription(StompProtocolManager.java:406) [hornetq-stomp-protocol.jar:]

                                  at org.hornetq.core.protocol.stomp.StompConnection.subscribe(StompConnection.java:711) [hornetq-stomp-protocol.jar:]

                                  at org.hornetq.core.protocol.stomp.VersionedStompFrameHandler.onSubscribe(VersionedStompFrameHandler.java:302) [hornetq-stomp-protocol.jar:]

                                  at org.hornetq.core.protocol.stomp.VersionedStompFrameHandler.handleFrame(VersionedStompFrameHandler.java:105) [hornetq-stomp-protocol.jar:]

                                  at org.hornetq.core.protocol.stomp.StompConnection.handleFrame(StompConnection.java:525) [hornetq-stomp-protocol.jar:]

                                  at org.hornetq.core.protocol.stomp.StompProtocolManager.handleBuffer(StompProtocolManager.java:158) [hornetq-stomp-protocol.jar:]

                                  at org.hornetq.core.protocol.stomp.StompConnection.bufferReceived(StompConnection.java:352) [hornetq-stomp-protocol.jar:]

                                  at org.hornetq.core.remoting.server.impl.RemotingServiceImpl$DelegatingBufferHandler.bufferReceived(RemotingServiceImpl.java:635) [hornetq-server.jar:]

                                  at org.hornetq.core.remoting.impl.netty.HornetQChannelHandler.channelRead(HornetQChannelHandler.java:73) [hornetq-core-client-2.4.1.Final.jar:]

                                  at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:338) [netty.jar:4.0.13.Final]

                                  at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:324) [netty.jar:4.0.13.Final]

                                  at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) [netty.jar:4.0.13.Final]

                                  at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:122) [netty.jar:4.0.13.Final]

                                  at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:485) [netty.jar:4.0.13.Final]

                                  at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:452) [netty.jar:4.0.13.Final]

                                  at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:346) [netty.jar:4.0.13.Final]

                                  at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:101) [netty.jar:4.0.13.Final]

                                  at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_05]

                          • 11. Re: Re: Error creating consumer with STOMP
                            Yong Hao Gao Master

                            hmm, looks like hornetQ thinks you have a selector (probably the empty string in your argument), can you try:

                             

                            IMessageConsumer consumer = session.CreateDurableConsumer(destination,"stompConsumer1234",null,true);


                            instead of


                            IMessageConsumer consumer = session.CreateDurableConsumer(destination,"stompConsumer1234","",true); 



                            • 12. Re: Re: Error creating consumer with STOMP
                              Yair Ogen Expert

                              I'm on holiday. I'll get back to you on Sunday.

                              • 13. Re: Re: Re: Error creating consumer with STOMP
                                Yair Ogen Expert

                                This seems to help a bit. no Errors but I can't seem to see any consumer regsitered in JConsole and indeed no message arrived.

                                 

                                Could it be ralated to a naming problem detailed here:

                                https://developer.jboss.org/message/594176

                                 

                                also - following this link:

                                 

                                http://www.gavincoates.com/Archive/2013/06/c-activemq-stomp

                                 

                                I have now this code that doesn't fail but message isn't sent. am I supposed to see this STOMP consumer somewhere in JConsole?

                                 

                                /*
                                 * Created by SharpDevelop.
                                 * User: yogen
                                 * Date: 23/09/2014
                                 * Time: 12:57
                                 * 
                                 * To change this template use Tools | Options | Coding | Edit Standard Headers.
                                 */
                                using System;
                                using Apache.NMS;
                                using Apache.NMS.Util;
                                
                                
                                
                                
                                namespace STOMPClient
                                {
                                  class Program
                                  {
                                  public static void Main(string[] args)
                                  {
                                  IConnectionFactory factory = new NMSConnectionFactory(new Uri("stomp:tcp://10.45.37.202:61613"));
                                
                                  IConnection connection = factory.CreateConnection();
                                // connection.ClientId="uniqueClient";
                                
                                  ISession session = connection.CreateSession();
                                
                                // ITopic destination = session.GetTopic("jms.topic.myExample");
                                // IQueue destination = session.GetQueue("jms.topic.myExample");
                                
                                // IMessageConsumer consumer = session.CreateDurableConsumer(destination,"jms.queue.stompConsumer1234",null,true);
                                
                                  IDestination destination = session.GetDestination("topic://myExample");
                                  if (destination == null)
                                  return;
                                  IMessageConsumer consumer = session.CreateConsumer(destination);
                                
                                  connection.Start();
                                
                                  consumer.Listener += new MessageListener(OnMessage);
                                
                                  Console.ReadLine();
                                  connection.Close();
                                
                                
                                  }
                                
                                  private static void OnMessage(IMessage message)
                                  {
                                  try
                                  {
                                  Console.WriteLine("Median-Server (.NET): Message received");
                                
                                
                                  ITextMessage msg = (ITextMessage)message;
                                  message.Acknowledge();
                                
                                
                                  Console.WriteLine(msg.Text);
                                  }
                                  catch (Exception ex)
                                  {
                                  Console.WriteLine(ex.Message);
                                  Console.WriteLine("---");
                                  Console.WriteLine(ex.InnerException);
                                  Console.WriteLine("---");
                                  Console.WriteLine(ex.InnerException.Message);
                                  }
                                  }
                                
                                
                                  }
                                }
                                
                                • 14. Re: Re: Re: Error creating consumer with STOMP
                                  Yong Hao Gao Master

                                  I'll try run your test code myself. By the way did you see any error logs ?

                                  1 2 Previous Next