-
1. Re: STOMP 1.1 problems with 2.3.0.Final
gaohoward May 5, 2013 10:33 PM (in response to mackerman)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
mackerman May 6, 2013 3:21 PM (in response to gaohoward)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
mackerman May 6, 2013 3:39 PM (in response to mackerman)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
gaohoward May 6, 2013 9:14 PM (in response to mackerman)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
mackerman May 7, 2013 10:03 AM (in response to gaohoward)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
mvkr May 31, 2013 12:45 PM (in response to mackerman)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
mackerman May 31, 2013 12:59 PM (in response to mvkr)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
mvkr Jun 3, 2013 4:43 AM (in response to mackerman)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
mackerman Jun 3, 2013 11:04 AM (in response to mvkr)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
mvkr Jun 4, 2013 3:02 AM (in response to mackerman)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,
-
Session.cs.zip 5.2 KB
-
-
11. Re: STOMP 1.1 problems with 2.3.0.Final
mackerman Jun 10, 2013 5:59 PM (in response to mvkr)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
-
Session.zip 5.2 KB
-
-
12. Re: STOMP 1.1 problems with 2.3.0.Final
mvkr Jun 11, 2013 3:48 AM (in response to mackerman)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
gochi Sep 26, 2013 1:57 AM (in response to mackerman)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
-
code.7z.zip 4.0 KB
-
-
14. Re: Re: STOMP 1.1 problems with 2.3.0.Final
gochi Sep 26, 2013 12:48 PM (in response to mvkr)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