2.19. Camel Spring Boot
camel-spring-boot 依赖项不再包含 camel-spring-xml。要在 Spring Boot 中使用旧的 Spring XML 文件 < ;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>
<camelContext id="SampleCamel" xmlns="http://camel.apache.org/schema/spring">
<restConfiguration port="8080" bindingMode="off" scheme="http"
contextPath="myapi" apiContextPath="myapi/swagger">
</restConfiguration>
由于循环引用错误,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 {
@SpringBootApplication(exclude = RestConfigurationDefinitionAutoConfiguration.class)
// load the spring xml file from classpath
@ImportResource("classpath:my-camel.xml")
public class SampleCamelApplication {
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("...")
from("platform-http:myservice")
.to("...")
然后调用 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。