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