骆驼:进口routeContext到外部camelContext [英] Camel: importing routeContext into an external camelContext

查看:796
本文介绍了骆驼:进口routeContext到外部camelContext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目中的骆驼背景:

I have a camel context in project A:

<camelContext id="camelContext">
    <route id="camelRoute1">
        <from uri="vm:foo" />
        <log message="camelRoute1 completed" />
    </route>
</camelContext>

项目B和项目C使用项目A作为Maven的依赖关系。

Project B and project C use project A as a Maven dependency.

项目B酒店的每一个,C定义自己的&LT; routeContext&GT; (在单独的XML文件):

Each one of the projects B and C defines their own <routeContext> (in separate xml files):

B项目:

<routeContext id="bRoutes" xmlns="http://camel.apache.org/schema/spring">
    <route id="barB">
        <from uri="direct:barB"/>
        <to uri="mock:barB"/>
    </route>
</routeContext>

项目C:

<routeContext id="cRoutes" xmlns="http://camel.apache.org/schema/spring">
    <route id="barC">
        <from uri="direct:barC"/>
        <to uri="mock:barC"/>
    </route>
</routeContext>

我要的项目,B和C的每一个能够为他们的路线(bRoutes和cRoutes)导入到骆驼语境camelContext,他们从项目中继承。

I want each one of the projects B and C to be able to import their routes ("bRoutes" and "cRoutes") into the camel context "camelContext" they inherited from project A.

我怎么能这样做呢?

如果我想补充

<routeContextRef ref="bRoutes"/>
<routeContextRef ref="cRoutes"/>

要在项目中的XML文件中,cRoutes不会被加载项目B当识别,bRoutes不会加载项目C当得到认可。

to the xml file in project A, "cRoutes" will not be recognized when loading project B, and "bRoutes" will not be recognized when loading project C.

推荐答案

这不符合一个好办法蓝图的工作,因为它是现在。因为我知道你不能从另一个XML文件导入camelcontext到当前你能做到这一点的纯Java DSL,但据

This does not work with blueprint in a good way as it is right now. You could do this with the pure Java DSL but as far as I know you CANNOT import camelcontext from another xml file into the current one.

基本上,如果你正在部署骆驼Karaf,您可以使用直接虚拟机项目A,B和C互相连接。因此,而不是直接:BARC你会写直接-VM:C

Basically if you are deploying your camel to Karaf you can use direct-vm to connect projects A,B and C with each other. So instead of direct:barC you'd write direct-VM:C.

这篇关于骆驼:进口routeContext到外部camelContext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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