Camel Concepts
A number of Camel architectural concepts are used throughout this book and are briefly explained here to provide a quick reference. Full details can be found on the Apache Camel website at http://camel.apache.org.
A Camel Exchange is a holder object that encapsulates the state of a conversation between systems. It contains properties, a variety of flags, a message exchange pattern or MEP (InOnly
or InOut
), and two messages (an In
message and an Out
message). Properties are expressed as a map of Strings to Objects, and are typically used by Camel and its components to store information pertaining to the processing of the exchange.
A message contains the payload to be processed by a processing step, as well as headers that are expressed as a map of Strings to Objects. You use headers to pass additional information about the message between processors. Headers are commonly used to override endpoint defaults.
An In
message is always present on an exchange as it enters a processor. The processor may modify the In
message or prepare a new payload and set it on the Out
message. If a processor sets the Out
message, the Camel context will move it to the In
message of the exchange before handing it to the next processor. For more, see http://camel.apache.org/exchange.html and http://camel.apache.org/message.html.
A Camel Processor is the base interface for all message-processing steps. Processors include predefined EIPs such as a Splitter, calls to endpoints, or custom processors that you have created implementing the org.apache.camel.Processor
interface. For more, see http://camel.apache.org/processor.html.
A Camel Route is a series of message processing steps defined using Camel's DSL. A Route always starts with one consumer endpoint within a from()
statement, and contains one or more processor steps. The processing steps within a route are loosely coupled, and do not invoke each other, relying on the Camel context instead to pass messages between them. For more, see http://camel.apache.org/routes.html.
The Camel Context is the engine that processes exchanges along the steps defined through routes. Messages are fed into a route based on a threading model appropriate to the component technologies being consumed from. Subsequent threading depends on the processors defined on the route.
A Camel Component is a library that encapsulates the communication with a transport or technology behind a common set of Camel interfaces. Camel uses these components to produce messages to or consume messages from those technologies. For a full list of components, see http://camel.apache.org/components.html.
A Camel Endpoint is an address that is interpreted by a component to identify a target resource, such as a directory, message queue, or database table that the component will consume messages from or send messages to. An endpoint used in a from()
block is known as a Consumer endpoint, while an endpoint used in a to()
block is known as a Producer endpoint. Endpoints are expressed as URIs, whose attributes are specific to their corresponding component. For more, see http://camel.apache.org/endpoint.html.
A Camel Expression is a way to script up Route in-line code that will operate on the message. For example, you can use the Groovy Expression Language to write inline Groovy code that can be evaluated on the in-flight message. Expressions are used within many EIPs to provide data to influence the routing of messages, such as providing the list of endpoints to route a message to as part of a Routing Slip EIP. For more, see http://camel.apache.org/expression.html.