搜索

63.13. Spring Boot Auto-Configuration

download PDF

在 Spring Boot 中使用 spring-rabbitmq 时,使用以下 Maven 依赖项来启用对自动配置的支持:

<dependency>
  <groupId>org.apache.camel.springboot</groupId>
  <artifactId>camel-spring-rabbitmq-starter</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>

组件支持下列 30 个选项。

Name描述默认值类型

camel.component.spring-rabbitmq.allow-null-body

是否允许在没有正文的情况下发送消息。如果此选项为 false,且消息正文为 null,则会抛出 MessageConversionException。

false

布尔值

camel.component.spring-rabbitmq.amqp-admin

可选的 AMQP Admin 服务用于自动声明元素(队列、交换、绑定)。选项是一个 org.springframework.amqp.core.AmqpAdmin 类型。

 

AmqpAdmin

camel.component.spring-rabbitmq.auto-declare

指定消费者是否应该在启动时自动声明交换、队列和路由密钥之间的绑定。启用这对开发可能很好,方便代理上的交换、队列和绑定。

false

布尔值

camel.component.spring-rabbitmq.auto-startup

指定消费者容器是否应自动启动。

true

布尔值

camel.component.spring-rabbitmq.autowired-enabled

是否启用自动关闭。这用于自动关闭选项(选项必须标记为 autowired),方法是在 registry 中查找查找是否有单个匹配类型实例,然后在组件上配置。这可以用于自动配置 JDBC 数据源、JMS 连接工厂、AWS 客户端等。

true

布尔值

camel.component.spring-rabbitmq.bridge-error-handler

允许将消费者桥接到 Camel 路由错误处理程序,这意味着当消费者试图选择传入消息或类似信息时发生异常,现在将作为消息处理并由路由 Error Handler 处理。默认情况下,使用者将使用 org.apache.camel.spi.ExceptionHandler 来处理例外情况,该处理程序将被记录在 WARN 或 ERROR 级别,并忽略。

false

布尔值

camel.component.spring-rabbitmq.concurrent-consumers

用户数量。

1

整数

camel.component.spring-rabbitmq.connection-factory

要使用的连接工厂。必须在组件或端点上配置连接工厂。选项是 org.springframework.amqp.rabbit.connection.ConnectionFactory 类型。

 

ConnectionFactory

camel.component.spring-rabbitmq.dead-letter-exchange

死信交换的名称。

 

字符串

camel.component.spring-rabbitmq.dead-letter-exchange-type

死信交换的类型。

direct

字符串

camel.component.spring-rabbitmq.dead-letter-queue

死信队列的名称。

 

字符串

camel.component.spring-rabbitmq.dead-letter-routing-key

死信交换的路由密钥。

 

字符串

camel.component.spring-rabbitmq.enabled

是否启用 spring-rabbitmq 组件的自动配置。这默认是启用的。

 

布尔值

camel.component.spring-rabbitmq.error-handler

使用自定义 ErrorHandler 处理消息监听器(consumer)中的异常。选项是一个 org.springframework.util.ErrorHandler 类型。

 

ErrorHandler

camel.component.spring-rabbitmq.header-filter-strategy

使用自定义 org.apache.camel.spi.HeaderFilterStrategy 将标头过滤到或从 Camel 消息过滤。选项是一个 org.apache.camel.spi.HeaderFilterStrategy 类型。

 

HeaderFilterStrategy

camel.component.spring-rabbitmq.ignore-declaration-exceptions

在声明时切换忽略异常,如不匹配的属性。

false

布尔值

camel.component.spring-rabbitmq.lazy-start-producer

生成者是否应懒惰启动 (在第一个消息中)。通过懒惰启动,您可以使用此选项来允许 CamelContext 和路由在生成者启动期间启动,并导致路由启动失败。通过懒惰启动,启动失败可以在路由信息时通过 Camel 的路由错误处理程序进行处理。请注意,在处理第一个消息时,创建并启动生成者可能需要稍等时间,并延长处理的总处理时间。

false

布尔值

camel.component.spring-rabbitmq.listener-container-factory

使用自定义工厂来创建和配置 ListenerContainer,供消费者用于接收消息。选项是 org.apache.camel.component.springrabbit.ListenerContainerFactory 类型。

 

ListenerContainerFactory

camel.component.spring-rabbitmq.max-concurrent-consumers

使用者的最大数量(仅适用于 SMLC)。

 

整数

camel.component.spring-rabbitmq.maximum-retry-attempts

如果 Camel 无法处理消息,则 Rabbitmq 使用者将重试相同的消息的次数。

5

整数

camel.component.spring-rabbitmq.message-converter

要使用自定义的 MessageConverter,以便您可以控制如何映射到 org.springframework.amqp.core.Message。选项是一个 org.springframework.amqp.support.converter.MessageConverter 类型。

 

MessageConverter

camel.component.spring-rabbitmq.message-listener-container-type

MessageListenerContainer 的类型。

DMLC

字符串

camel.component.spring-rabbitmq.message-properties-converter

要使用自定义 MessagePropertiesConverter,以便您可以控制如何映射到 org.springframework.amqp.core.MessageProperties。选项是 org.apache.camel.component.springrabbit.MessagePropertiesConverter 类型。

 

MessagePropertiesConverter

camel.component.spring-rabbitmq.prefetch-count

告知代理在单个请求中发送到每个消费者的消息数量。通常,这可以设置得非常高,以提高吞吐量。

250

整数

camel.component.spring-rabbitmq.reject-and-dont-requeue

Rabbitmq 使用者是否应该拒绝消息,而无需重新排队。这可让配置了代理,将失败的消息发送到 Dead Letter Exchange/Queue。

true

布尔值

camel.component.spring-rabbitmq.reply-timeout

在执行请求/回复消息时,指定在等待回复消息时使用的超时时间(以毫秒为单位)。默认值为 5 秒。负值表示一个不正确的超时。选项是一个长类型。

5000

Long

camel.component.spring-rabbitmq.retry

要使用的自定义重试配置。如果这被配置,则不会使用用于重试的 maximumRetryAttempts 等其他设置。选项是一个 org.springframework.retry.interceptor.RetryOperationsInterceptor 类型。

 

RetryOperationsInterceptor

camel.component.spring-rabbitmq.retry-delay

在 msec 中,Rabbitmq 消费者将在 Camel 无法处理的消息前等待。

1000

整数

camel.component.spring-rabbitmq.shutdown-timeout

容器停止后,等待 worker 的时间(以毫秒为单位)。如果有任何 worker 在关闭信号进入时处于活跃状态,只要这些程序可以在这个超时时间内结束,就可以完成处理。选项是一个长类型。

5000

Long

camel.component.spring-rabbitmq.test-connection-on-startup

指定是否在启动时测试连接。这样可确保 Camel 启动所有 JMS 用户与 JMS 代理的有效连接。如果无法授予连接,则 Camel 会在启动时抛出异常。这样可确保 Camel 没有使用失败的连接启动。JMS producer 也经过测试。

false

布尔值

Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

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

让开源更具包容性

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

關於紅帽

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

© 2024 Red Hat, Inc.