2.19. Camel Spring Boot


camel-spring-boot 依赖项不再包含 camel-spring-xml。要在 Spring Boot 中使用旧的 Spring XML 文件 &lt ;beans > 和 Camel,然后包括 camel-spring-boot-xml-starter 依赖项。

2.19.1. 在 Spring Bean XML 中使用 restConfiguration

在 Spring Beans XML 文件中声明 restConfiguration 时,例如:

<camelContext id="SampleCamel" xmlns="http://camel.apache.org/schema/spring">
    <restConfiguration port="8080" bindingMode="off" scheme="http"
                       contextPath="myapi" apiContextPath="myapi/swagger">
    </restConfiguration>
Copy to Clipboard Toggle word wrap

由于循环引用错误,Camel Spring Boot 应用程序不会启动。当您使用 Spring 属性配置 REST 组件时,使用 RestConfigurationDefinitionAutoConfiguration 属性。当您在 XML 文件中定义 REST 配置时,不需要 RestConfigurationDefinitionAutoConfiguration 属性。您可以按照以下方式禁用此属性:

SampleCamelApplication.java

@SpringBootApplication(exclude = RestConfigurationDefinitionAutoConfiguration.class)
// load the spring xml file from classpath
@ImportResource("classpath:my-camel.xml")
public class SampleCamelApplication {
Copy to Clipboard Toggle word wrap

2.19.2. 安全关闭

Camel 现在稍后在 Spring Boot 关闭过程中关闭一个位。这允许 Spring Boot 安全关闭先完成(正常停止 Spring Boot HTTP 服务器),然后在 Camel 后执行自己的 Graceful Shutdown

技术上 camel-spring 已将 getPhase () 从返回 Integer.MAX_VALUE 改为 Integer.MAX_VALUE - 2049。这为 Spring Boot 服务提供了首先关闭的空间。

2.19.3. camel-micrometer-starter

uri 标签现在是静态的,而不是动态(默认),因为带有动态值的 URI 而导致潜在的标签太多。这可以通过设置 camel.metrics.uriTagDynamic=true 来再次启用。

2.19.4. camel-platform-http-starter

platform-http-starter 已从使用 camel-servlet 改为直接使用 Spring HTTP 服务器。因此,所有 HTTP 端点不再带有 servlet context-path 前缀(默认为 camel)。

例如:

from("platform-http:myservice")
  .to("...")
Copy to Clipboard Toggle word wrap

然后调用 myservice 需要包含上下文路径,如 http://localhost:8080/camel/myservice。现在,context-path 没有被使用,端点可以通过 http://localhost:8080/myservice 调用。

注意

platform-http-starter 也可用于 Rest DSL。

如果路由或消费者暂停,则现在返回 http 状态 503,而不是 404。

2.19.5. camel-twitter

该组件已更新为使用 Whereabouts4j 版本 4.1.2,它已移动了几个类所使用的 软件包。如果访问某些与 twitter 相关的数据,如 Twit 状态,您需要将 twitter4j.Status 中使用的软件包更新为 twitter4j.v1.Status

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

Theme

© 2025 Red Hat