Passing values between processors in apache camel

前端 未结 4 1053
太阳男子
太阳男子 2020-12-08 07:28

In apache camel, which of those is the best way to pass values from an exchange processor to another (and why) :

  • storing it in the exchange headers
  • us
4条回答
  •  星月不相逢
    2020-12-08 07:54

    the Exchange is passed between Processors. It contains properties, IN message and optional OUT message. Each of these is capable of storing Object data, but in general:

    • use the Exchange Properties for general meta-data about the message (used less frequently)
    • use the IN message headers to configure endpoint properties or for meta-data about the message body (used often)
    • use the IN message body for the payload of the message (used most often)
    • create an OUT message only if necessary to maintain separate IN vs. OUT messages during processing (by default only IN is used)

    That said, it really depends on the component called following your processor. Most have some headers and/or body values that are required to use the endpoint, etc. See the specific component page for these details.

    Also, the Exchange/Message are explained in more detail on these pages:

    http://camel.apache.org/maven/current/camel-core/apidocs/org/apache/camel/Exchange.html

    http://fusesource.com/docs/router/2.8/prog_guide/MsgFormats-Exchanges.html

提交回复
热议问题