Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Using Annotations to bind parameters to the Exchange

Info
title[Bean] component

The annotations below is part of camel-core and its Bean component and thus does not require camel-spring. These annotations is to be used with the Bean component.

...

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

Using Expression Languages

You can also use any of the Languages supported in Camel to bind expressions to method parameters when using bean integration. For example you can use any of these annotations:

...

Code Block
public class Foo {
	
    @MessageDriven(uri = "activemq:my.queue")
    public void doSomething(@XPath("/foo/bar/text()") String correlationID, @Body String body) {
		// process the inbound message here
    }
}

Advanced example using @Bean

And an example of using the the @Bean binding annotation, where you can use a POJO where you can do whatever java code you like:

...