15.6. 例子
用于消耗消息的对象实例必须明确注册到 Registry。例如,如果您使用 Spring,则必须在 Spring 配置 XML 文件中定义 bean。
您还可以使用 bind 方法通过 Camel 的 Registry 手动注册 Bean。
注册了端点后,您可以构建使用它来处理交换的 Camel 路由。
bean: 端点无法定义为路由的输入;例如,您无法使用来自它的输入,您只能从一些入站消息 Endpoint 中作为输出路由到 bean 端点。因此,请考虑使用 direct: 或 queue: endpoint 作为输入。
您可以使用 ProxyHelper 上的 createProxy () 方法来创建将生成交换并将其发送到任何端点的代理:
和使用 XML DSL 的同一路由:
<route> <from uri="direct:hello"/> <to uri="bean:bye"/> </route>
<route>
<from uri="direct:hello"/>
<to uri="bean:bye"/>
</route>