0

I have a simple route in camel, which reads messages from an activemq queue 'A' and writes it to another activemq queue 'B'.I was able to get this to this part to work.

But I need to add a new property to the message before writing it to 'B'. I have tried to add the property 'prop1' to the message using the Spring DSL below, but the property is not being added to the message.

<camelContext xmlns="http://camel.apache.org/schema/spring">
     <route>
        <from uri="activemq:queue:A"/>
          <setProperty propertyName="prop1">
            <simple>prop1Value</simple>
          </setProperty>
        <to uri="activemq:queue:B"/>
     </route>               
  </camelContext>

Is this the correct way to add a property to a message in SPRING DSL?

user1717230
  • 443
  • 1
  • 15
  • 30

1 Answers1

3

Use a header instead of a property:

<route>
    <from uri="activemq:queue:A"/>
    <setHeader headerName="prop1">
        <constant>prop1Value</constant>
    </setHeader>
    <to uri="activemq:queue:B"/>
</route>               
<route>
    <from uri="activemq:queue:B" />
    <log message="prop1 = ${header.prop1}" />
</route>

Camel headers are transferred to JMS properties which are transferred back to Camel headers as can be seen looking at the implementation of org.apache.camel.component.jms.JMSBinding. The Camel properties are skipped.

Peter Keller
  • 7,526
  • 2
  • 26
  • 29
  • Thanks for the response..But, does camel not make a distinction between a message header vs message properties ? How come camel sees "prop1" as a header, whereas activemq sees it as a property of the message? – user1717230 Mar 21 '14 at 15:56
  • I added a link to JMSBinding where all the data transfer is done. For the comparison between header and properties see http://stackoverflow.com/questions/10330998/passing-values-between-processors-in-apache-camel – Peter Keller Mar 21 '14 at 17:56