Camel - content enricher: enrich() vs pollEnrich()

和自甴很熟 提交于 2019-12-01 16:46:42
Ben ODay

Here is the difference:

  • enrich assumes you want to use an incoming Exchange as a parameter to an another service request. for example, your incoming Exchange could be a userID, but you really need the entire User object, so you could enrich it by passing the userID to a REST service that returns the User object which becomes the Exchange, etc.

  • pollEnrich assumes the incoming Exchange is a simple trigger that tell a PollingConsumer to look for data and create an Exchange (ignoring the contents of the incoming Exchange). For example, you could have a timer or other business process event that requires picking up a file for processing, etc. that said, the incoming Exchange data is NOT used to dynamically configure the PollingConsumer...only the URI is used for this.

That said, as of Camel 2.12, there is an option to specify an aggregation strategy to combine the incoming/returned Exchanges for both enrich and pollEnrich

See this unit test for an example of pollEnrich with an aggregation strategy

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