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

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

问题描述

我是Apache Camel的新手.

I am new to Apache Camel.

我的要求是在我的代码流中从方法A()触发Apache骆驼路线.另外,我需要将A()的对象参数传递给路由.我不想使用amq,文件等组件.

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"
}

做到这一点的最佳方法是什么?

What's the best way to do this?

推荐答案

您可以使用ProducerTemplate选项,ProducerTemplate template = exchange.getContext().createProducerTemplate(),然后可以执行template.sendBodysendBody方法可以直接调用骆驼路由.

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天全站免登陆