如何从我的 java 方法触发 Apache 骆驼路由 [英] How to trigger Apache camel route from my java method
问题描述
我是 Apache Camel 的新手.
I am new to Apache Camel.
我的要求是在我的代码流中从方法 A() 触发 Apache 骆驼路由.我还需要将 A() 的对象参数传递给路由.我不想使用 amq、file 等组件.
My requirement is to trigger an Apache camel route in my code flow from method A(). Also I need to pass the object param of A() to the route. I do not want to use amq, file etc components.
代码:
public void A(MyObjectType param) {
//Need to call camel route with "param"
}
最好的方法是什么?
推荐答案
你可以使用 ProducerTemplate 选项,ProducerTemplate template = exchange.getContext().createProducerTemplate() 然后你就可以做 template.sendBodysendBody方法可以直接调用camel路由.
You can use the ProducerTemplate option, ProducerTemplate template = exchange.getContext().createProducerTemplate() and then you can do template.sendBody The sendBody method can invoke a camel route directly.
这篇关于如何从我的 java 方法触发 Apache 骆驼路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!