LibraryLink ToToggle FramesPrintFeedback

Implementing a Simple Processor

This section describes how to implement a simple processor that executes message processing logic before delegating the exchange to the next processor in the route.

Simple processors are created by implementing the org.apache.camel.Processor interface. As shown in Example 2.2, the interface defines a single method, process(), which processes an exchange object.

To create a simple processor you must implement the Processor interface and provide the logic for the process() method. Example 2.3 shows the outline of a simple processor implementation.

All of the code in the process() method gets executed before the exchange object is delegated to the next processor in the chain.

For examples of how to access the message body and header values inside a simple processor, see Accessing Message Content.

Use the process() DSL command to insert a simple processor into a route. Create an instance of your custom processor and then pass this instance as an argument to the process() method, as follows:

org.apache.camel.Processor myProc = new MyProcessor();