我们在 Spring Boot 上使用 Camel,我们有下面的 application.yml 属性文件来配置一些 camel 设置。
我想优雅地关闭我的应用程序和骆驼路线,所以我使用 DefaultShutdownStrategy,但是我不知道我需要在我的 application.yml 中使用什么属性来启用它?
我也无法在网上找到任何地方,任何人都可以对此有所了解。或者你会如何建议实施正常关机。
# Camel configuration:
camel:
component:
servlet:
# With multiple camel servlets running within the same process you need to set the servlet name.
# The servlet name is named after the port to ensure uniqueness without having to bring in a new parameter.
servlet-name: camelServlet${SERVER_PORT:9000}
springboot:
name: pilot-manager-service
main-run-controller: true
routes-include-pattern: classpath:routes/**/*.xml,classpath:route-templates/*.xml
据我了解,在 Camel 中默认启用
DefaultShutdownStrategy
的正常关机。
以下是 application.yml 的文档 中 3.20.x 的默认值。
camel:
springboot:
shutdown-log-inflight-exchanges-on-timeout: true
shutdown-now-on-timeout: true
shutdown-routes-in-reverse-order: true
shutdown-suppress-logging-on-timeout: false
shutdown-timeout: 300
请注意,在单元测试期间,camel 似乎至少忽略了关机超时值,而是使用 10 秒。
您还可以执行 custom camel 上下文配置,您可以在其中将 camel 上下文关闭策略设置为
DefaultShutdownStrategy
的新实例,您可以使用自己的属性占位符进行配置。但是请注意,@PropertySource
注释可能需要对 yaml 文件进行一些额外的工作。