- Mastering Apache Camel
- Jean-Baptiste Onofré
- 465字
- 2021-07-16 13:50:22
Messages
Messages transport the data between the different parts of the mediation logic. Your mediation logic will define the flow of messages between different nodes.
A message flows in one direction, from a sender to a receiver. It's not possible to use the same message to answer the sender, we will have to use another message. A message is described in the org.apache.camel.Message
interface.
The javadoc is available at http://camel.apache.org/maven/camel-2.13.0/camel-core/apidocs/org/apache/camel/Message.html.
A message contains the following:
- ID: A message ID of type
String
. Camel creates an ID for you. This ID identifies the message and can be used for correlation or storage. For instance, we will see that the message ID is used in the idempotent consumer pattern to identify the message in a store. - Header: A set of headers, allowing you to store any kind of data associated with a message. The headers are stored as
org.apache.camel.util.CaseInsensitiveMap
by default. TheCaseInsensitiveMap
(http://camel.apache.org/maven/camel-2.13.0/camel-core/apidocs/org/apache/camel/util/CaseInsensitiveMap.html) extendsHashMap<String,Object>
. This means you can store any kinds of objects (including very large objects) in the header. To access the map use aString
key, which is case insensitive. The lifetime of the headers is the same as the message (as the headers are part of the message itself). The purpose of the headers is to add hints about the content encoding, authentication information, and so on. As we will see in the next chapters, Camel itself uses and populates the headers for its own needs and configurations. - Attachment: A set of attachments is mostly to match the requirements of some protocols and components: WebService component (to provide SOAP Message Transmission Optimization Mechanism (MTOM) support) or the e-mail component (to provide support for e-mail attachments). The attachments are only used by some dedicated components, they are not as heavily used as the headers. The attachments are stored in the message as
Map<String,DataHandler>
. An attachment name is aString
, which is case sensitive. An attachment is stored usingDataHandler
providing support of MIME type and consistent access to the data. - Fault flag: A fault flag Boolean that allows you to distinguish whether the message is a normal message or a faulted message. It allows some components or patterns to treat the message in a different way. For instance, instead of a SOAP Response, a message may contain a SOAP Fault. In that case, we have to inform the component that a message containing a SOAP Fault is not a normal message.
- Body: The body is the actual payload of the message. The body is stored as an
Object
in the message, allowing you to store any kind of data. In Chapter 1, Key Features we saw that one of the Camel key features is to be payload-agnostic. The fact that the body is directly anObject
is the implementation of the payload-agnostic feature.
推薦閱讀
- Mastering Entity Framework Core 2.0
- Visual Basic程序設(shè)計(jì)教程
- Java FX應(yīng)用開(kāi)發(fā)教程
- Servlet/JSP深入詳解
- Visual Basic程序設(shè)計(jì)習(xí)題解答與上機(jī)指導(dǎo)
- HTML5 and CSS3 Transition,Transformation,and Animation
- 時(shí)空數(shù)據(jù)建模及其應(yīng)用
- Node.js 12實(shí)戰(zhàn)
- 大學(xué)計(jì)算機(jī)基礎(chǔ)實(shí)訓(xùn)教程
- Python第三方庫(kù)開(kāi)發(fā)應(yīng)用實(shí)戰(zhàn)
- C語(yǔ)言編程魔法書(shū):基于C11標(biāo)準(zhǔn)
- ASP.NET Core 2 High Performance(Second Edition)
- Serverless工程實(shí)踐:從入門到進(jìn)階
- Mastering Unity 2017 Game Development with C#(Second Edition)
- ACE技術(shù)內(nèi)幕:深入解析ACE架構(gòu)設(shè)計(jì)與實(shí)現(xiàn)原理