An exchange in Camel is the message’s container during routing. An exchange also provides support for the various types of interactions between systems, also known as message exchange patterns (MEPs). MEPs are used to differentiate between one-way and request-response messaging styles. 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.
Camel中的exchange是路由过程中消息的容器。exchange还为系统之间的各种类型的交互提供支持,也称为消息交换模式(mep)。MEP用于区分单向和请求-响应消息传递样式。Camel exchange拥有一个模式属性,该属性可以是
■InOnly—单向消息(也称为事件消息)。例如,JMS消息传递通常是单向消息传递。
■InOut—请求-响应消息。例如,基于HTTP的传输通常是request-reply,客户机请求检索网页,等待服务器的回复。
■ Exchange ID—A unique ID that identifies the exchange. Camel will generate a default unique ID, if you don’t explicitly set one.
■ MEP—A pattern that denotes whether you’re using the InOnly or InOut messaging style. When the pattern is InOnly, the exchange contains an in message. For InOut, an out message also exists that contains the reply message for the caller.
■ 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. Camel itself will add various properties to the exchange during routing. You, as a developer, can store and retrieve properties at any point during the lifetime of an exchange.
■ 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.
■Exchange ID—标识交换的唯一ID。如果没有显式设置,Camel将生成一个默认的唯一ID。
■MEP—表示您使用的是InOnly还是InOut消息传递样式的模式。当模式为InOnly时,交换包含in消息。对于InOut,还存在一个out消息,其中包含调用者的回复消息。
■Exception 异常如果在路由过程中的任何时候发生错误,将在异常字段中设置异常。
■Properties 类似于消息头的属性,但它们在整个交换期间都有效。属性用于包含全局级别的信息,而消息头是特定于特定消息的。Camel本身将在路由过程中向交换添加各种属性。作为开发人员,您可以在exchange生命周期的任何时候存储和检索属性。
■In message,这是输入信息,是强制性的。in消息包含请求消息。
■Out message 这是一个可选消息,仅在MEP输入输出时存在。out消息包含回复消息。
We discussed Camel’s message model before the architecture because we wanted you to have a solid understanding of what a message is in Camel. After all, the most important aspect of Camel is routing messages. You’re now well prepared to learn more about Camel and its architecture.
我们在架构之前讨论了Camel的消息模型,因为我们希望您对Camel中的消息有一个坚实的理解。毕竟,Camel最重要的方面是路由消息。现在,您已经准备好了解更多有关Camel及其体系结构的信息。