如何从我的 java 方法触发 Apache 骆驼路由 [英] How to trigger Apache camel route from my java method

查看:26
本文介绍了如何从我的 java 方法触发 Apache 骆驼路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆