Camel概念【Exchange 】

杀马特。学长 韩版系。学妹 提交于 2020-03-02 08:00:53

Exchange

An exchange in Camel is the message’s container during routing. (在camel中,exchange被当做路由交换的容器)

An exchange also provides support for the various types of interactions between systems, also known as message exchange patterns ( MEP s).  MEP s are used to differentiate between one-way and request-response messaging styles. The Camel exchange holds a pattern property that can be either

(exchange还为不同种类的系统交互提供了支持,这也被称作消息交互模式,MEP用于区分单向和交互的信息请求,exchange有着这样的模式特性:)
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.
Figure 1.5 illustrates the contents of an exchange in Camel.

Let’s look at the elements of figure 1.5 in more detail:
Exchange  ID —A unique  ID that identifies the exchange. Camel will generate a default unique  ID ,if you don’t explicitly set one.(Exchange  ID 唯一id标识exchange,如果不显式的设置id值,camel将自动生成默认id)
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.(记录InOnly或InOut的模式)

Exception—If an error occurs at any time during routing, an  Exception will be set in the exception field.
Properties—Similar to message headers(和message中的header很相似), but they last for the duration of the entire exchange. (但他在整个exchange过程中持续)Properties are used to contain global-level information(Properties用于存放全局信息), where as 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.(在路由交换时,camel自身将向exchange中添加种类繁多的property,作为开发者的你,可以在exchange生命周期的任何时间点存取property
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 (当模式为Inout时,才有).The out message contains the reply message.


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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!