How to receive messages from ActiveMQ with JMSTemplate and a selector?

activemq-classic, java, jms, spring

Solution

Facepalm! JMSCorrelationID is case sensitive. I was trying to use JMSCorrelationId...

Problem

I'm trying to grab messages on a persistent activemq queue. If I call ``` jmsTemplate.receive("queue.response") ``` I get a message. However if I call ``` jmsTemplate.receiveSelected("queue.response", "JMSCorrelationId='1854044'") ``` I time out while waiting. I'm looking at the queue using the ActiveMQ web console and I can see that the messages are there ready to be consumed. The correlation ids are visible in the console and I can also see them in the messages I receive with the straight receive("queue..") call. Presumably I'm doing something wrong with my actual selector, but every example I can find looks like what I've got. Any ideas what I'm doing wrong?

Original source