Versions Compared

Key

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

...

To consume a message you use either the @MessageDriven annotation or from 1.5.0 the @Consume annotation to mark a particular method of a bean as being a consumer method. The uri of the annotation defines the Camel Endpoint to consume from.

What this does is basically create a route that looks kinda like this

Code Block

from(uri).bean(theBean, "methodName");

The Bean Binding is then used to convert the inbound Message to the parameter list used to invoke the method

e.g. lets invoke the onCheese() method with the String body of the inbound JMS message from ActiveMQ on the cheese queue; this will use the Type Converter to convert the JMS ObjectMessage or BytesMessage to a String - or just use a TextMessage from JMS

Code Block
public class Foo {

  @MessageDriven(uri="activemq:cheese")
  public void onCheese(String name) {
    ...
  }
}

The Bean Binding is then used to convert the inbound Message to the parameter list used to invoke the method .

What this does is basically create a route that looks kinda like this

Code Block

from(uri).bean(theBean, "methodName");

Using an explicit route

If you want to invoke a bean method from many different endpoints or within different complex routes in different circumstances you can just use the normal routing DSL or the Spring XML configuration file.

...