简体   繁体   中英

Camel: importing routeContext into an external 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>

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM