0

I am using Spring JMS 4.1.2, and I am using org.springframework.messaging.Message as the input payload in the JMS Listener. I am listening to an Active MQ Queue, and I would like to know if it is possible to obtain the JMSXDeliveryCount and JMSDestination using the org.springframework.messaging.Message, or if I have to use the javax.jms.Message class to accomplish this.

Thanks,

Juan

jcb
  • 195
  • 1
  • 4
  • 20

1 Answers1

1

The delivery count property is mapped by default; I just ran a test...

message: GenericMessage [payload=jms test, headers={jms_redelivered=true, JMSXDeliveryCount=2, ...

Standard headers are mapped with a jms_ prefix all; message properties are mapped as-is.

The destination from which the message is received is not currently mapped to the message.

You would need to add a custom JmsHeaderMapper - perhaps a subclass of DefaultJmsHeaderMapper.

I opened a JIRA issue to make this standard.

Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Hi Gary! - Thanks for the prompt reply! I will try and implement a subclass of the DefaultJmsHeaderMapper. I would like to know how I can integrate it. I will have a look. – jcb Mar 17 '16 at 14:14
  • Hi Gary - Looks like it all works out of the box like you mentioned above. I had to ensure that the test that I was running had thrown a runtime exception in order to get the delivery count. Also, the Jms Messaging Template uses the SimpleJmsHeaderMapper instead of the DefaultJmsHeaderMapper (from spring integration). Also, the JMSDestination is defined as jms_destination in the Message instead. Thanks for the info Gary! I am marking this as the correct solution! – jcb Mar 17 '16 at 16:37
  • Thanks; yes; I'll still fix the DJHM to map the dest, though. – Gary Russell Mar 22 '16 at 19:02