Camel: importing routeContext into an external camelContext

主宰稳场 提交于 2019-12-14 03:16:21

问题


I have a camel context in project A:

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

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

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

Project B:

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

Project C:

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

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.

How could I do this?

If I add

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

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.


回答1:


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.

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.



来源:https://stackoverflow.com/questions/34244019/camel-importing-routecontext-into-an-external-camelcontext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!