RabbitMQ Producer Properties

在使用 Spring Cloud Stream 与 RabbitMQ 集成时,可以单独为每个通道设置属性,也可以将属性设置为所有通道的默认值,避免重复配置。特定绑定属性的值将覆盖其在默认值中的同等值。

以下属性仅适用于 Rabbit 生产者,且必须使用 spring.cloud.stream.rabbit.bindings.<channelName>.producer. 前缀。

然而,如果需要将同一组属性应用于大多数绑定,可通过 Spring Cloud Stream 设置所有通道的值(格式为 spring.cloud.stream.rabbit.default.<property>=<value>),避免重复。

另外,请记住,特定绑定属性的值将覆盖其在默认值中的等值。

altermateExchange.binding.queue

If the exchange does not already exist, and a name is provided, bind this queue to the alternate exhange. A simple durable queue with no arguments is provisioned; if more sophisticated configuration is required, you must configure and bind the queue yourself.

默认:nullalternateExchange.binding.routingKey,如果交换机还不存在,且提供了 namequeue,则使用此路由键将队列绑定到备用交换机。 默认:#(为默认 topic 备用交换机)

alternateExchange.exists

Whether the alternate exchange exists, or needs to be provisioned.

默认值:false

alternateExchange.type

If the alternate exchange does not already exist, the type of exchange to provision.

默认:topic

alternateExchange.name

Configure an alternate exchange on the destination exchange.

默认值:null

autoBindDlq

Whether to automatically declare the DLQ and bind it to the binder DLX.

默认:false.

batchingEnabled

Whether to enable message batching by producers. Messages are batched into one message according to the following properties (described in the next three entries in this list): 'batchSize', batchBufferLimit, and batchTimeout. See Batching for more information. Also see Receiving Batched Messages.

默认:false.

batchSize

The number of messages to buffer when batching is enabled.

默认:100

batchBufferLimit

The maximum buffer size when batching is enabled.

默认值:10000

batchTimeout

The batch timeout when batching is enabled.

默认:5000

bindingRoutingKey

The routing key with which to bind the queue to the exchange (if bindQueue is true). Can be multiple keys - see bindingRoutingKeyDelimiter. For partitioned destinations, -n is appended to each key. Only applies if requiredGroups are provided and then only to those groups.

默认:#

bindingRoutingKeyDelimiter

When this is not null, 'bindingRoutingKey' is considered to be a list of keys delimited by this value; often a comma is used. Only applies if requiredGroups are provided and then only to those groups.

默认值:null

bindQueue

Whether to declare the queue and bind it to the destination exchange. Set it to false if you have set up your own infrastructure and have previously created and bound the queue. Only applies if requiredGroups are provided and then only to those groups.

默认:“true”。

compress

Whether data should be compressed when sent.

默认:false.

confirmAckChannel

When errorChannelEnabled is true, a channel to which to send positive delivery acknowledgments (aka publisher confirms). If the channel does not exist, a DirectChannel is registered with this name. The connection factory must be configured to enable publisher confirms. Mutually exclusive with useConfirmHeader.

默认:nullChannel(丢弃 ack)。

deadLetterQueueName

The name of the DLQ Only applies if requiredGroups are provided and then only to those groups.

默认:prefix+destination.dlq

deadLetterExchange

A DLX to assign to the queue. Relevant only when autoBindDlq is true. Applies only when requiredGroups are provided and then only to those groups.

默认:prefix+DLX

deadLetterExchangeType

The type of the DLX to assign to the queue. Relevant only if autoBindDlq is true. Applies only when requiredGroups are provided and then only to those groups.

默认:direct

deadLetterRoutingKey

A dead letter routing key to assign to the queue. Relevant only when autoBindDlq is true. Applies only when requiredGroups are provided and then only to those groups.

默认:destination

declareDlx

Whether to declare the dead letter exchange for the destination. Relevant only if autoBindDlq is true. Set to false if you have a pre-configured DLX. Applies only when requiredGroups are provided and then only to those groups.

默认:“true”。

declareExchange

Whether to declare the exchange for the destination.

默认:“true”。

delayExpression

A SpEL expression to evaluate the delay to apply to the message (x-delay header). It has no effect if the exchange is not a delayed message exchange.

默认:未设置 x-delay 标头。

delayedExchange

Whether to declare the exchange as a Delayed Message Exchange. Requires the delayed message exchange plugin on the broker. The x-delayed-type argument is set to the exchangeType.

默认:false.

deliveryMode

The delivery mode.

默认值:PERSISTENT

dlqBindingArguments

Arguments applied when binding the dlq to the dead letter exchange; used with headers deadLetterExchangeType to specify headers to match on. For example …​dlqBindingArguments.x-match=any, …​dlqBindingArguments.someHeader=someValue. Applies only when requiredGroups are provided and then only to those groups.

默认值:空

dlqDeadLetterExchange

When a DLQ is declared, a DLX to assign to that queue. Applies only if requiredGroups are provided and then only to those groups.

默认值:none

dlqDeadLetterRoutingKey

When a DLQ is declared, a dead letter routing key to assign to that queue. Applies only when requiredGroups are provided and then only to those groups.

默认值:none

dlqExpires

How long (in milliseconds) before an unused dead letter queue is deleted. Applies only when requiredGroups are provided and then only to those groups.

默认值:no expiration

dlqLazy

Declare the dead letter queue with the x-queue-mode=lazy argument. See “Lazy Queues”. Consider using a policy instead of this setting, because using a policy allows changing the setting without deleting the queue. Applies only when requiredGroups are provided and then only to those groups.

dlqMaxLength

Maximum number of messages in the dead letter queue. Applies only if requiredGroups are provided and then only to those groups.

默认值:no limit

dlqMaxLengthBytes

Maximum number of total bytes in the dead letter queue from all messages. Applies only when requiredGroups are provided and then only to those groups.

默认值:no limit

dlqMaxPriority

Maximum priority of messages in the dead letter queue (0-255) Applies only when requiredGroups are provided and then only to those groups.

默认值:none

dlqQuorum.deliveryLimit

When quorum.enabled=true, set a delivery limit after which the message is dropped or dead-lettered. Applies only when requiredGroups are provided and then only to those groups.

默认值:无,将应用代理默认值。

dlqQuorum.enabled

When true, create a quorum dead letter queue instead of a classic queue. Applies only when requiredGroups are provided and then only to those groups.

默认值:false

dlqQuorum.initialGroupSize

When quorum.enabled=true, set the initial quorum size. Applies only when requiredGroups are provided and then only to those groups.

默认值:无,将应用代理默认值。

dlqSingleActiveConsumer

Set to true to set the x-single-active-consumer queue property to true. Applies only when requiredGroups are provided and then only to those groups.

默认值:false

dlqTtl

Default time (in milliseconds) to live to apply to the dead letter queue when declared. Applies only when requiredGroups are provided and then only to those groups.

默认值:no limit

exchangeAutoDelete

If declareExchange is true, whether the exchange should be auto-delete (it is removed after the last queue is removed).

默认:“true”。

exchangeDurable

If declareExchange is true, whether the exchange should be durable (survives broker restart).

默认:“true”。

exchangeType

The exchange type: direct, fanout, headers or topic for non-partitioned destinations and direct, headers or topic for partitioned destinations.

默认值:topic

expires

How long (in milliseconds) before an unused queue is deleted. Applies only when requiredGroups are provided and then only to those groups.

默认值:no expiration

headerPatterns

Patterns for headers to be mapped to outbound messages.

默认值: ['*'](所有头)。

lazy

Declare the queue with the x-queue-mode=lazy argument. See “Lazy Queues”. Consider using a policy instead of this setting, because using a policy allows changing the setting without deleting the queue. Applies only when requiredGroups are provided and then only to those groups.

默认:false.

maxLength

Maximum number of messages in the queue. Applies only when requiredGroups are provided and then only to those groups.

默认值:no limit

maxLengthBytes

Maximum number of total bytes in the queue from all messages. Only applies if requiredGroups are provided and then only to those groups.

默认值:no limit

maxPriority

Maximum priority of messages in the queue (0-255). Only applies if requiredGroups are provided and then only to those groups.

默认值:none

prefix

A prefix to be added to the name of the destination exchange.

默认值:""。

producerType

The type of producer.

  • `AMQP`经典队列和仲裁队列的 AMQP 客户端

  • `STREAM_SYNC`RabbitMQ Streams 插件客户端,在收到确认之前会阻塞

  • `STREAM_ASYNC`RabbitMQ Streams 插件客户端,不阻塞默认值:""。

queueBindingArguments

Arguments applied when binding the queue to the exchange; used with headers exchangeType to specify headers to match on. For example …​queueBindingArguments.x-match=any, …​queueBindingArguments.someHeader=someValue. Applies only when requiredGroups are provided and then only to those groups.

默认值:空

queueNameGroupOnly

When true, consume from a queue with a name equal to the group. Otherwise the queue name is destination.group. This is useful, for example, when using Spring Cloud Stream to consume from an existing RabbitMQ queue. Applies only when requiredGroups are provided and then only to those groups.

默认值:false。

quorum.deliveryLimit

When quorum.enabled=true, set a delivery limit after which the message is dropped or dead-lettered. Applies only when requiredGroups are provided and then only to those groups.

默认值:无,将应用代理默认值。

quorum.enabled

When true, create a quorum queue instead of a classic queue. Applies only when requiredGroups are provided and then only to those groups.

默认值:false

quorum.initialGroupSize

When quorum.enabled=true, set the initial quorum size. Applies only when requiredGroups are provided and then only to those groups.

默认值:无,将应用代理默认值。

routingKeyExpression

A SpEL expression to determine the routing key to use when publishing messages. For a fixed routing key, use routingKey.

默认值:对于已分区的目标,为 destinationdestination-<partition>

routingKey

A string defining a fixed routing key to use when publishing messages.

默认值:请参阅 routingKeyExpression

singleActiveConsumer

Set to true to set the x-single-active-consumer queue property to true. Applies only when requiredGroups are provided and then only to those groups.

默认值:false

transacted

Whether to use transacted channels.

默认:false.

ttl

Default time (in milliseconds) to live to apply to the queue when declared. Applies only when requiredGroups are provided and then only to those groups.

默认值:no limit

useConfirmHeader

See Publisher Confirms. Mutually exclusive with confirmAckChannel.

就 RabbitMQ 而言,外部应用程序可以设置内容类型标头。Spring Cloud Stream 将它们作为用于任何类型的传输的扩展内部协议的一部分提供支持——包括 本身不支持标头的传输(例如早期的 Kafka(介于 0.11 之前))。