Templates by BIGtheme NET

Camel Fundamentals

Camel’s message model
In Camel, there are two abstractions for modeling messages.
1) org.apache.camel.Message—
The fundamental entity containing the data being carried and routed in Camel.
2) org.apache.camel.Exchange—
The Camel abstraction for an exchange of messages. This exchange of messages has an “in” message and as a reply, an “out” message.

Message
1) Messages are the entities used by systems to communicate with each other when using
messaging channels.
2) Messages flow in one direction from a sender to a receiver. Messages have a body (a payload), headers,
and optional attachments.
3) Messages are uniquely identified with an identifier of type java.lang.String. The identifier’s
uniqueness is enforced and guaranteed by the message creator, it’s protocol dependent, and it doesn’t
have a guaranteed format.
1
4) Headers are values associated with the message, such as sender identifiers, hints about content
encoding, authentication information,and so on.

Exchange
1) An exchange in Camel is the message’s container during routing.
2) An exchange also provides support for the various types of interactions between systems, also known as
message exchange patterns (MEPs).
3) MEPs are used to differentiate between one-way and request-response messaging styles.
4) The Camel exchange holds a pattern property that can be either.
InOnly—A one-way message (also known as an Event message). For example, JMS
messaging is often one-way messaging.
InOut—A request-response message. For example, HTTP-based transports are often request reply, where a client requests to retrieve a web page, waiting for the reply from the server.
2
Exchange ID—A unique ID that identifies the exchange. Camel will generate a default unique ID.
MEP—A pattern that denotes whether you’re using the InOnly or InOut messaging style.
Exception—If an error occurs at any time during routing, an Exception will be set in the exception field.
Properties—Similar to message headers, but they last for the duration of the entire exchange. Properties are used to contain global-level information,whereas message headers are specific
to a particular message.
In message—This is the input message, which is mandatory. The in message contains
the request message.
Out message—This is an optional message that only exists if the MEP is InOut.
The out message contains the reply message.

PRODUCER :
1) A producer is the Camel abstraction that refers to an entity capable of creating and
sending a message to an endpoint.
2) When a message needs to be sent to an endpoint, the producer will create an exchange and populate
it with data compatible with that particular endpoint.
3
3) For example, a FileProducer will write the message body to a file. A JmsProducer, on the other hand, will map the Camel message to a javax.jms.Message before sending it to a JMS destination.
4) This is an important feature in Camel, because it hides the complexity of interacting with particular
transports.
5) All we need to do is route a message to an endpoint, and the producer does the heavy lifting.