Camel:将 routeContext 导入外部 camelContext [英] Camel: importing routeContext into an external camelContext

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

问题描述

我在项目 A 中有一个骆驼上下文:

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 中的每一个都定义了自己的 (在单独的 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")导入到它们从项目 A 继承的骆驼上下文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"/>

对于项目A中的xml文件,加载项目B时不会识别cRoutes",加载项目C时不会识别bRoutes".

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.

推荐答案

这与现在的蓝图不兼容.您可以使用纯 Java DSL 执行此操作,但据我所知,您不能将来自另一个 xml 文件的 camelcontext 导入当前文件.

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,您可以使用 direct-vm 将项目 A、B 和 C 相互连接.因此,您应该编写 direct-VM:C 而不是 direct:barC.

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.

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

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