Results 1 to 4 of 4

Thread: spllitter messages loose "correlationId" header when going through activemq queue

  1. #1
    Join Date
    Oct 2012
    Posts
    3

    Post spllitter messages loose "correlationId" header when going through activemq queue

    Hello,

    I'm currently using spring-integration-jms (version 2.1.3.RELEASE) and ActiveMQ version 5.6.0. I have a message(job) that I'm splitting via Spring Integration's splitter. The splitter automatically sets 3 headers that an aggregator can use later: correlationId, sequenceSize, and sequenceNumber. All 3 headers makes it through to the aggregator ok if it never passes through the ActiveMQ queue. If it passes through ActiveMQ, the sequenceSize and sequenceNumber is intact, but correlationId is gone. A couple of new headers is present if it passes through ActiveMQ: jms_timestamp, jms_redelivered, jms_correlationId, jms_replyTo, jms_messageId. The jms_correlationId value appears completely unrelated to the Spring Integration's "correlationId" set by the splitter.

    Has anyone else run into this problem or has any idea on what might cause this behavior?

    Thanks.
    Last edited by kdo; Oct 16th, 2012 at 03:31 PM.

  2. #2
    Join Date
    Oct 2012
    Posts
    3

    Default

    Did a little more testing for this issue and found that the value for Spring Integration's "correlationId" is an UUID type. Only value type header values seem to be passing through the ActiveMQ queue. Did some testing where I created my own custom headers where the value is an UUID. The custom header is gone once it passes through ActiveMQ. If I set the value of the custom header to UUID.toString(), then it is still intact when it comes out of the queue.

  3. #3
    Join Date
    Jan 2009
    Location
    Ukraine, Kharkov
    Posts
    740

    Default

    Hello!

    If I set the value of the custom header to UUID.toString(), then it is still intact
    Frankly speaking, you're going the right way.
    The real issue is here: org.springframework.integration.jms.DefaultJmsHead erMapper.SUPPORTED_PROPERTY_TYPES
    There is no supported type for java.util.UUID.
    So, I recommend you write some custom JmsHeaderMapper:
    Code:
    public class CorrelationIdJmsHeaderMapper extends DefaultJmsHeaderMapper {
    
    		public void fromHeaders(MessageHeaders headers, javax.jms.Message jmsMessage) {
    			super.fromHeaders(headers, jmsMessage);
    			Object correlationId = headers.get(MessageHeaders.CORRELATION_ID);
    			if (correlationId != null) {
    				try {
    					jmsMessage.setStringProperty("correlationId", correlationId.toString());
    				}
    				catch (Exception e) {
    					throw new MessagingException("Problem setting 'correlationId' property", e);
    				}
    			}
    		}
    
    	}
    And use like this:
    HTML Code:
    <jms:outbound-channel-adapter destination="someDestination" header-mapper="correlationIdJmsHeaderMapper"/>
    However you can raise new JIRA issue https://jira.springsource.org/browse/INT and we will think what to do in the framework.

    Cheers,
    Artem

  4. #4
    Join Date
    Oct 2012
    Posts
    3

    Default

    Thank you for the info. I will submit this as a new JIRA issue.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •