Apache Camel:处理器和 Bean 的用途相同吗? [英] Apache Camel: do Processors and Beans serve the same purpose?
问题描述
似乎两者都有相同的目的.有什么区别可以使某些情况下有用而其他情况下有用吗?
It seems like both serve the same purpose. Is there any difference that makes one useful in certain situations and not the other ?
推荐答案
在实践中,它们非常相似,但 Processor 比 Bean 更受限制.我通常将处理器用于仅与 Exchange 交互的简单用例.此外,内联处理器是一种无需创建单独的类即可进行交互的好方法.
In practice, they are very similar, but a Processor is more limited than a Bean. I generally use a Processor for simple use cases that just interact with the Exchange. Also, inline processors are a great way to interact without having to create a separate class.
Beans 提供了更多的灵活性,并且还支持真正的 POJO 方法.这使您可以更轻松地与现有 API 集成(只需将输入/输出转换为匹配等).
Beans provide more flexibility and also support a true POJO approach. This allows you to more easily integrate with existing APIs (just need to convert the inputs/outputs to match, etc).
Beans 还提供了与 Camel 路由/EIP 集成相关的强大功能/灵活性,包括...
Beans also provide great features/flexibility with regards to Camel routing/EIP integration, including...
丰富的绑定,允许您快速绑定来自交换 bean 方法的属性等.
rich set of bindings that allow you to quickly bind data from the Exchange to attributes of a bean method, etc.
POJO 消费/production 允许您以可重用的方式与端点交互
POJO consuming/producing allow you to interact with endpoints in a reusable manner
用作表达式/谓词(用于 POJO EIP 实现...过滤器等)
used as expressions/predicates (for POJO EIP implementation...filters, etc)
这篇关于Apache Camel:处理器和 Bean 的用途相同吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!