-
1. Re: Somp client to publish and subscribe queues in HornetQ
gaohoward Sep 5, 2012 6:00 AM (in response to mvkr)Can you give the piece of your code for publishing and receiving ?
Howard
-
2. Re: Somp client to publish and subscribe queues in HornetQ
mvkr Sep 5, 2012 6:56 AM (in response to gaohoward)Hi Howard,
Here is the code that I am using.
// For publishing a text message
ConnectionFactory cf = new ConnectionFactory("tcp://localhost:61613");
IConnection connection = cf.CreateConnection();
ISession session = connection.CreateSession();
IDestination destination = session.GetDestination("test");
connection.Start();
IMessageProducer producer = session.CreateProducer(destination);
producer.DeliveryMode = MsgDeliveryMode.Persistent;
ITextMessage messg = session.CreateTextMessage("Some Text");
producer.Send(messg);
// For receiving the message published by publisher
ConnectionFactory cf = new ConnectionFactory("tcp://localhost:61613");
IConnection connection = cf.CreateConnection();
ISession session = connection.CreateSession();
IDestination destination = session.GetDestination("test");
connection.Start();
IMessageConsumer consumer = session.CreateConsumer(destination); // Exception thown at this line
At the point when I create a consumer the hornetq is throwing an exception
-
3. Re: Somp client to publish and subscribe queues in HornetQ
gaohoward Sep 5, 2012 7:31 AM (in response to mvkr)Thanks. I don't how the client translates the destination name into Stomp frame headers. I had run some example long before and the syntax for getting a destination is something like
session.GetDestination("queue://test");
Not sure if it still works. Anyway you can get a tcp monitor tool to make sure the destination 'test' is translated into 'jms.queue.test' down in the Stomp layer.
Howard
-
4. Re: Somp client to publish and subscribe queues in HornetQ
mvkr Sep 10, 2012 7:05 AM (in response to gaohoward)Hai Howard,
I am using the syntax provided by the C# stomp client. But I also changed the syntax and tried it but it always raises this exception. I tried to use the stomp client for java and it worked without any problem, may be there is a problem with the stomp client in c#. Any way I reported this problem to my boss. We may think of changing HornetQ to ActiveMQ. Thanks for your response.
Thanks and Regards,
vijay.
-
5. Re: Somp client to publish and subscribe queues in HornetQ
mjustin Sep 21, 2012 7:45 AM (in response to mvkr)Your code
IDestination destination = session.GetDestination("test");
seems not to specify wether it is a Topic or Queue destination.
The examples for the ActiveMQ NMS C# client on http://activemq.apache.org/nms/examples.html are:
// Hard coded destinations:
// IDestination destination = session.GetQueue("FOO.BAR");
// Debug.Assert(destination is IQueue);
// IDestination destination = session.GetTopic("FOO.BAR");
// Debug.Assert(destination is ITopic);
//
// Embedded destination type in the name:
// IDestination destination = SessionUtil.GetDestination(session, "queue://FOO.BAR");
// Debug.Assert(destination is IQueue);
// IDestination destination = SessionUtil.GetDestination(session, "topic://FOO.BAR");
// Debug.Assert(destination is ITopic);
//
// Defaults to queue if type is not specified:
// IDestination destination = SessionUtil.GetDestination(session, "FOO.BAR");
// Debug.Assert(destination is IQueue);
//
// .NET 3.5 Supports Extension methods for a simplified syntax:
// IDestination destination = session.GetDestination("queue://FOO.BAR");
// Debug.Assert(destination is IQueue);
// IDestination destination = session.GetDestination("topic://FOO.BAR");
// Debug.Assert(destination is ITopic);Did you try these?
-
6. Re: Somp client to publish and subscribe queues in HornetQ
mvkr Sep 24, 2012 11:16 AM (in response to mjustin)Hai Michael,
Actually it was not the problem with the declaration of topic or a queue in my program. HornetQ doesnot support the declaration of a topic or queue in the form "destination:/queue/ExampleQueue". This was reported in the post https://community.jboss.org/message/594176. However, there is a work around provided in this post. The apache nms library in .net has to be slightly modified to declare queues and topics as"jms.queue.ExampleQueue" instead of "/queue/ExampleQueue". I followed these instructions and finally made it worked. Thanks for your reply.
Regards,
Vijay.
-
7. Re: Somp client to publish and subscribe queues in HornetQ
inmatevip May 22, 2014 12:40 AM (in response to mvkr)Here's a small tutorial for C# that I created in case anyone is interested: