Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: CAMEL-1378

...

The follow annotations @Headers, @OutHeaders and @Properties binds to the backing java.util.Map so you can alter the content of these maps directly, for instance using the put method to add a new entry. See the OrderService class at Exception Clause for such an example.

Since Camel 2.0, you can use @Header("myHeader") and @Property("myProperty") instead of @Header(name="myHeader") and @Property(name="myProperty") as Camel 1.x does.

Example

In this example below we have a @Consume consumer (like message driven) that consumes JMS messages from the activemq queue. We use the @Header and @Body parameter binding annotations to bind from the JMSMessage to the method parameters.

Code Block
public class Foo {
	
    @Consume(uri = "activemq:my.queue")
    public void doSomething(@Header(name = "JMSCorrelationID") String correlationID, @Body String body) {
		// process the inbound message here
    }

}

...

Code Block
public class Foo {
    public void doSomething(@Header(name = "JMSCorrelationID") String correlationID, @Body String body) {
		// process the inbound message here
    }

}

...

Code Block
    public void doSomething(@Header(name = "user") String user, @Body String body, Exchange exchange) {
        exchange.getIn().setBody(body + "MyBean");
    }

...