Announcement Announcement Module
Collapse
No announcement yet.
spllitter messages loose "correlationId" header when going through activemq queue Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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, 03:31 PM.

  • #2
    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.

    Comment


    • #3
      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

      Comment


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

        Comment

        Working...
        X