xmaverick
xmaverick

Reputation: 23

How do I identify a message using JMS Correlation ID?

How do I identify a message using JMS Correlation ID? I'm using code like the following, but I can't get the message out of the queue. The tool has confirmed that there is a message in the queue with JMSCorrelationID ='ID: 1234567' set in PropertiesText. What's wrong? Is it possible to include spaces in the value specified for JMSCorrelationID? Is it possible to use a value like 'ID: 1234 ABC'?

Sender:

    MessageProducer mproducer;
    Session qSession;
    ...
    String selectKey = "'' ID: 1234567'";
    ObjectMessage msg = qSession.createObjectMessage (data);
    msg.setJMSCorrelationID (selectKey);
    mProducer.send (msg);

Receiver

    Session qSession;
    ...
    String selectMsgKey = "JMSCorrelationID ='ID: 1234567'";
    MessageConsumer mConsumer.createConsumer (queue, selectMsgKey);
    mConsumer.receive (60000);

I use ActiveMQ Artemis.

Upvotes: 1

Views: 1940

Answers (1)

Justin Bertram
Justin Bertram

Reputation: 35093

You can have spaces in a correlation ID. I believe the problem is the way you're defining selectKey in your sender. You have extra ' characters in there. You should simply use:

String selectKey = "ID: 1234567";

Then your selector should work.

Upvotes: 1

Related Questions