搜索

6.14. 在类路径中添加 XML 路由以进行自动配置

download PDF

默认情况下,Camel Spring Boot 组件会自动探测,并包含 camel 目录中的 classpath 中的 Camel XML 路由。您可以使用配置选项配置目录名称或禁用此功能。

流程

  • 在类路径中配置 Camel Spring Boot XML 路由,如下所示:

    // turn off
    camel.springboot.xmlRoutes = false
    // scan in the com/foo/routes classpath
    camel.springboot.xmlRoutes = classpath:com/foo/routes/*.xml
    注意

    XML 文件应该定义 Camel XML 路由元素而不是 CamelContext 元素,例如:

       <routes xmlns="http://camel.apache.org/schema/spring">
            <route id="test">
                <from uri="timer://trigger"/>
                <transform>
                    <simple>ref:myBean</simple>
                </transform>
                <to uri="log:out"/>
            </route>
        </routes>

使用 Spring XML 文件

要将 Spring XML 文件与 <camelContext> 搭配使用,您可以在 Spring XML 文件或 application.properties 文件中配置 Camel 上下文。要设置 Camel 上下文的名称并打开流缓存,请在 application.properties 文件中添加以下内容:

camel.springboot.name = MyCamel
camel.springboot.stream-caching-enabled=true
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.