0
votes

I am using Spring integration JMS Outbound adapter to send message to IBM MQ and I found that some of JMS headers coming from the upstream application is missed out or defaulted. The upstream application is sending the below JMS headers,

JMSType:
JMSDeliveryMode:
JMSExpiration:
JMSPriority:
JMSMessageID:
JMSTimestamp:
JMSCorrelationID: JMSDestination:
JMSReplyTo:
JMSRedelivered:

After going through Spring's DefaultJmsHeaderMapper conversion, the below Headers are defaulted/missed.

JMSPriority:
JMSDeliveryMode:
JMSExpiration:
JMSRedelivered:
JMSReplyTo:

I enabled explicit-qos flag in JMS Outbound adapter and I do see Priority. But Still have issues with other Headers.

2

2 Answers

0
votes

This is simplified version what is mapped by the DefaultJmsHeaderMapper on the inbound part:

public Map<String, Object> toHeaders(javax.jms.Message jmsMessage) {
    Map<String, Object> headers = new HashMap<String, Object>();
        headers.put(JmsHeaders.MESSAGE_ID, messageId);
        headers.put(JmsHeaders.DESTINATION, destination);
        headers.put(JmsHeaders.CORRELATION_ID, correlationId);
        headers.put(JmsHeaders.REPLY_TO, replyTo);
        headers.put(JmsHeaders.REDELIVERED, jmsMessage.getJMSRedelivered());
        headers.put(JmsHeaders.TYPE, type);
        headers.put(JmsHeaders.TIMESTAMP, jmsMessage.getJMSTimestamp());
        if (this.mapInboundPriority) {
            headers.put(IntegrationMessageHeaderAccessor.PRIORITY, jmsMessage.getJMSPriority());
        }
        Enumeration<?> jmsPropertyNames = jmsMessage.getPropertyNames();
            while (jmsPropertyNames.hasMoreElements()) {
                String propertyName = jmsPropertyNames.nextElement().toString();
                String headerName = this.toHeaderName(propertyName);
                    headers.put(headerName, jmsMessage.getObjectProperty(propertyName));
                }
            }
        }
    return headers;
}

Would you mind to share logs how does the message look after on sending to the message channel for the JmsMessageDrivenEndpoint?

OTOH you always can extend/override the default and provide your own JmsHeaderMapper implementation.

0
votes

If present, they are mapped from the JMS headers to spring-messaging headers:

GenericMessage [payload=sdf, headers={
jms_redelivered=false, 
jms_destination=queue://queue.demo, 
id=899e931b-7f77-3e92-9b95-349c0fc57afe, 
priority=4, 
jms_timestamp=1496695959175, 
jms_messageId=ID:gollum.local-65233-1496695954961-4:1:2:1:1, timestamp=1496695965782}]

The only one I see missing is JMSDeliveryMode. With the exception of priority, they are prefxed with jms_.

Not all brokers supply the delivery mode on incoming messages; it generally only applies to outbound. If you can confirm that your broker does indeed provide the delivery mode on inbound messages, we can add the mapping (and/or you can do it in a subclass of the default mapper). Open a JIRA issue with evidence (e.g. a screenshot of a debugger for an inbound message) if you want the mapping added.