While debugging my application to see why it was so slow, I found from the MQ activity trace that my replies were all persistent.
The first problem was that by default all jms messages are persistent, so I used
int deliveryMode = message.getJMSDeliveryMode();
to get the persistence of the input message,
and used the obvious code to set the JMSDeliveryMode,
TextMessage response = session.createTextMessage("my reply"); response.setJMSDeliveryMode(deliveryMode);
to set it the same as the input message. I reran my test and the reply was still persistent.
Eventually I found you need
producer = session.createProducer(dest); producer.setDeliveryMode(deliveryMode);
And this worked! It is all explained here.
How do I check?
You can either check your code (bearing in mind that this may be hidden by the productivity tools you use ( Swing, Camel etc)), or turn on activity trace for a couple of seconds to check.
One thought on “Are all your jms messages persistent?”