Versions Compared

Key

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

A message is the smallest unit for transmitting data in a messaging system and the message itself might have some internal structure. When two different application systems are connected via a Message Channel and they need to exchange information, then that data can be packaged into an agnostic object called a Message. This is a generic container of data and any object can be provided as the message payload. Therefore, any data that needs to be transmitted in a messaging system must be converted into a Message.

Image Added

Image Removed

Table of Contents

By encapsulating the data in a generic wrapper like Message object, the messaging system can pass it around without any knowledge of the data’s type. As an application evolves to support new types or when the types themselves are modified or extended, the messaging system is not affected.

...

  • body - the message body (i.e. payload)

  • headers - headers with additional information

  • messageId - Unique id of the message.

  • timestamp - The timestamp of the message

Types of Message

Apache Camel defines the following distinct message types:

  • In message  —  A message that travels through a route from a consumer endpoint to a producer endpoint (typically, initiating a message exchange).

    Out message  —  A message that travels through a route from a producer endpoint back to a consumer endpoint (usually, in response to an In message).

Message structure

By default, it applies the following structure to all message types:

  • Headers  —  Contains metadata or header data extracted from the message.

  • Body  —  Usually contains the entire message in its original form.

  • Attachments  —  Message attachments (required for integrating with certain messaging systems

NOTE: It is important to remember that this separation into headers, body, and attachments is just an abstract model of the message. Apache Camel supports many different components, and they can generate a wide variety of message formats. Ultimately, it is the underlying component implementation that decides what gets placed into the headers and body of a message.

Correlating messages

Internally, Apache Camel remembers the message IDs, which are used to correlate individual messages together. In practice, however, the most important way that Apache Camel correlates messages is via exchange objects.

Exchange objects

An exchange object is an entity that encapsulates related messages, where the collection of related messages is referred to as a message exchange,and the rules governing the sequence of messages are referred to as an exchange pattern. For example, two common exchange patterns are one-way event messages (consisting of an In message), and request-reply exchanges (consisting of an In message, followed by an Out message).