如何在春季加载多个骆驼上下文 [英] How load multiple camel context in spring

查看:8
本文介绍了如何在春季加载多个骆驼上下文的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Spring Java应用程序中上传多个CAMEL上下文文件(camel-context.xml;camel-context2.xml)。我正在尝试以下上传文件的方式。但只有一个文件被加载。

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

在下面的快照中,控制台蓝色标记为成功响应,红色表示错误。

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

推荐答案

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

已删除对多个CamelContext的支持,并且每个部署仅支持一个CamelContext。后者无论如何都不被推荐,也没有100%实现(例如,在CAMEL-CDI中)。对于骆驼3,建议和支持每个部署仅1个骆驼上下文。

但您可以通过以下方式分隔您的路由配置,因为这仍然是一个骆驼上下文。https://camel.apache.org/manual/latest/faq/how-do-i-import-routes-from-other-xml-files.html

文件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>

文件2:(文件1已导入)

<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>

这篇关于如何在春季加载多个骆驼上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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