2

I want to upload multiple camel context files ( camel-context.xml ; camel-context2.xml ) in spring java application. I am trying the below way to upload files. But only single file gets loaded.

@SpringBootApplication
@ImportResource({"classpath:camel*.xml"})

In the below snapshot in console blue marked gives success response , red shows error.

enter image description here

Note : I have tried this approach as well . Didnt workout.
@ImportResource("camel-context.xml", "camel-context2.xml")
Nithish
  • 61
  • 10

1 Answers1

1

https://camel.apache.org/manual/latest/camel-3-migration-guide.html#_multiple_camelcontexts_per_application_not_supported

Support for multiple CamelContexts has been removed and only 1 CamelContext per deployment is supported. The latter was not recommended anyway and was also not 100% implemented (for example in camel-cdi). For Camel 3 only 1 CamelContext per deployment is recommended and supported.

But you can do the following way of separating your route configurations as this is still one camel context. https://camel.apache.org/manual/latest/faq/how-do-i-import-routes-from-other-xml-files.html

File 1:

<beans ....">

    <routeContext id="myCoolRoutes" xmlns="http://camel.apache.org/schema/spring">

        <route id="cool">
            <from uri="direct:start"/>
            <to uri="mock:result"/>
        </route>
        <route id="bar">
            <from uri="direct:bar"/>
            <to uri="mock:bar"/>
        </route>
    </routeContext>
</beans>

File 2: (File 1 is imported)

<beans ..>
    
    <import resource="myCoolRoutes.xml"/>

    <camelContext xmlns="http://camel.apache.org/schema/spring">

        <routeContextRef ref="myCoolRoutes"/>

        <route id="inside">
            <from uri="direct:inside"/>
            <to uri="mock:inside"/>
        </route>
    </camelContext>

</beans>
Community
  • 1
  • 1