Changes in 2.2 Since 2.1
-
将类和接口从
org.springframework.amqp.rabbit.core.support
移动到org.springframework.amqp.rabbit.batch
-
JUnit (4) 成为可选依赖项,JUnit (5) 的`RabbitAvailableCondition.getBrokerRunning()` 返回不同的实例
-
改进了侦听器容器性能监控和消息处理
-
增强了
@RabbitListener
注解,包括支持批处理和覆写容器工厂属性 -
添加了对 Spring 数据投影接口和 Jackson 转换器的改进支持
-
引入了新的消息后处理器,用于压缩和解压缩
-
改进了对交换和队列声明的流利 API 支持和错误恢复功能
本节介绍了 2.1 版和 2.2 版之间的更改。
This section describes the changes between version 2.1 and version 2.2.
Package Changes
以下类/接口已从 org.springframework.amqp.rabbit.core.support
移至 org.springframework.amqp.rabbit.batch
:
The following classes/interfaces have been moved from org.springframework.amqp.rabbit.core.support
to org.springframework.amqp.rabbit.batch
:
-
BatchingStrategy
-
MessageBatch
-
SimpleBatchingStrategy
此外,ListenerExecutionFailedException
已从 org.springframework.amqp.rabbit.listener.exception
移至 org.springframework.amqp.rabbit.support
。
In addition, ListenerExecutionFailedException
has been moved from org.springframework.amqp.rabbit.listener.exception
to org.springframework.amqp.rabbit.support
.
Dependency Changes
JUnit (4) 现在是可选依赖项,不再显示为传递依赖项。
JUnit (4) is now an optional dependency and will no longer appear as a transitive dependency.
spring-rabbit-junit
模块现在是 spring-rabbit-test
模块中的 编译 依赖项,以便在仅使用单个 spring-rabbit-test
时获得 AMQP 组件的完整测试实用程序栈,从而获得更好的目标应用程序开发体验。
The spring-rabbit-junit
module is now a compile dependency in the spring-rabbit-test
module for a better target application development experience when with only a single spring-rabbit-test
we get the full stack of testing utilities for AMQP components.
[[-breaking-api-changes]]== “破坏性”API更改
[[-breaking-api-changes]] == "Breaking" API Changes
JUnit (5) RabbitAvailableCondition.getBrokerRunning()
现在返回 BrokerRunningSupport
实例,而不是依赖于 JUnit 4 的 BrokerRunning
。它具有相同的 API,所以只需更改任何引用的类名即可。参见 JUnit5 Conditions 了解更多信息。
the JUnit (5) RabbitAvailableCondition.getBrokerRunning()
now returns a BrokerRunningSupport
instance instead of a BrokerRunning
, which depends on JUnit 4.
It has the same API so it’s just a matter of changing the class name of any references.
See JUnit5 Conditions for more information.
ListenerContainer Changes
默认情况下,带有致命异常的消息现已被拒绝,而不会再次加入队列,即使确认模式为手动模式。有关更多信息,请参见Exception Handling。
Messages with fatal exceptions are now rejected and NOT requeued, by default, even if the acknowledge mode is manual. See Exception Handling for more information.
现在可以使用Micrometer`Timer`对监听器性能进行监控。有关更多信息,请参见Monitoring Listener Performance。
Listener performance can now be monitored using Micrometer Timer
s.
See Monitoring Listener Performance for more information.
@RabbitListener Changes
您现在可以在每个侦听器上配置 executor
,覆盖工厂配置,以更轻松地识别与侦听器关联的线程。您现在可以使用注释的 ackMode
属性覆盖容器工厂的 acknowledgeMode
属性。参见 overriding container factory properties 了解更多信息。
You can now configure an executor
on each listener, overriding the factory configuration, to more easily identify threads associated with the listener.
You can now override the container factory’s acknowledgeMode
property with the annotation’s ackMode
property.
See overriding container factory properties for more information.
使用batching时, `@RabbitListener`方法现在可以在一个调用中接收一批完成的消息,而不必一次接收一条。
When using batching, @RabbitListener
methods can now receive a complete batch of messages in one call instead of getting them one-at-a-time.
在一次接收一批消息时,最后一条消息的 isLastInBatch
消息属性被设置为 true。
When receiving batched messages one-at-a-time, the last message has the isLastInBatch
message property set to true.
此外,接收到的批处理消息现在包含 amqp_batchSize
标头。
In addition, received batched messages now contain the amqp_batchSize
header.
监听器也可以使用`SimpleMessageListenerContainer`中创建的批次,即使该批次不是由生产者创建的。有关更多信息,请参见Choosing a Container。
Listeners can also consume batches created in the SimpleMessageListenerContainer
, even if the batch is not created by the producer.
See Choosing a Container for more information.
Jackson2JsonMessageConverter
现支持 Spring 数据投影接口。参见 Using Spring Data Projection Interfaces 了解更多信息。
Spring Data Projection interfaces are now supported by the Jackson2JsonMessageConverter
.
See Using Spring Data Projection Interfaces for more information.
如果不存在 contentType
属性,或它是默认值 (application/octet-string
),则 Jackson2JsonMessageConverter
现在假定内容是 JSON。参见 Converting from a Message
了解更多信息。
The Jackson2JsonMessageConverter
now assumes the content is JSON if there is no contentType
property, or it is the default (application/octet-string
).
See Converting from a Message
for more information.
类似地,如果不存在 contentType
属性,或它是默认值 (application/octet-string
),则 Jackson2XmlMessageConverter
现在假定内容为 XML。参见 Jackson2XmlMessageConverter
了解更多信息。
Similarly. the Jackson2XmlMessageConverter
now assumes the content is XML if there is no contentType
property, or it is the default (application/octet-string
).
See Jackson2XmlMessageConverter
for more information.
当`@RabbitListener`方法返回结果时,bean和`Method`现在可以在回复消息属性中获取。这允许配置`beforeSendReplyMessagePostProcessor`,例如,设置回复中的头,以指示在服务器上调用的方法。有关更多信息,请参见Reply Management。
When a @RabbitListener
method returns a result, the bean and Method
are now available in the reply message properties.
This allows configuration of a beforeSendReplyMessagePostProcessor
to, for example, set a header in the reply to indicate which method was invoked on the server.
See Reply Management for more information.
你现在可以配置`ReplyPostProcessor`,以便在发送回复消息之前对其进行修改。有关更多信息,请参见Reply Management。
You can now configure a ReplyPostProcessor
to make modifications to a reply message before it is sent.
See Reply Management for more information.
AMQP Logging Appenders Changes
Log4J 和 Logback AmqpAppender
现在支持 verifyHostname
SSL 选项。
The Log4J and Logback AmqpAppender
s now support a verifyHostname
SSL option.
这些追加器现在可以配置为不将 MDC 条目添加为标头。addMdcAsHeaders
布尔选项已引入以配置此类行为。
Also these appenders now can be configured to not add MDC entries as headers.
The addMdcAsHeaders
boolean option has been introduces to configure such a behavior.
追加器现在支持 SaslConfig
属性。
The appenders now support the SaslConfig
property.
有关更多信息,请参见Logging Subsystem AMQP Appenders。
See Logging Subsystem AMQP Appenders for more information.
MessageListenerAdapter Changes
MessageListenerAdapter
现在提供了一个新的 buildListenerArguments(Object, Channel, Message)
方法来构建要传递给目标侦听器和已弃用的旧数组。参见 MessageListenerAdapter
了解更多信息。
The MessageListenerAdapter
provides now a new buildListenerArguments(Object, Channel, Message)
method to build an array of arguments to be passed into target listener and an old one is deprecated.
See MessageListenerAdapter
for more information.
[[exchange/queue-declaration-changes]]== Exchange/队列声明更改
[[exchange/queue-declaration-changes]] == Exchange/Queue Declaration Changes
现在,用于创建 Exchange
和 Queue
对象以供 RabbitAdmin
声明的 ExchangeBuilder
和 QueueBuilder
Fluent API 支持“众所周知”的参数。参见 Builder API for Queues and Exchanges 了解更多信息。
The ExchangeBuilder
and QueueBuilder
fluent APIs used to create Exchange
and Queue
objects for declaration by RabbitAdmin
now support "well known" arguments.
See Builder API for Queues and Exchanges for more information.
RabbitAdmin
具有新属性 explicitDeclarationsOnly
。有关详细信息,请参见 Conditional Declaration。
The RabbitAdmin
has a new property explicitDeclarationsOnly
.
See Conditional Declaration for more information.
Connection Factory Changes
CachingConnectionFactory
具有新属性 shuffleAddresses
。在提供代理节点地址列表时,该列表将在创建连接之前被打乱,以使尝试连接的顺序是随机的。有关详细信息,请参见 Connecting to a Cluster。
The CachingConnectionFactory
has a new property shuffleAddresses
.
When providing a list of broker node addresses, the list will be shuffled before creating a connection so that the order in which the connections are attempted is random.
See Connecting to a Cluster for more information.
在使用发布者确认和返回时,现在在连接工厂的 executor
上调用回调。这将避免在 amqp-clients
库中执行一些 Rabbit 操作导致潜在死锁。有关详细信息,请参见 Correlated Publisher Confirms and Returns。
When using Publisher confirms and returns, the callbacks are now invoked on the connection factory’s executor
.
This avoids a possible deadlock in the amqp-clients
library if you perform rabbit operations from within the callback.
See Correlated Publisher Confirms and Returns for more information.
此外,现在使用 ConfirmType
枚举指定发布者确认类型,而不是两个互斥的 setter 方法。
Also, the publisher confirm type is now specified with the ConfirmType
enum instead of the two mutually exclusive setter methods.
现在,在启用 SSL 时,RabbitConnectionFactoryBean
默认使用 TLS 1.2。有关详细信息,请参见 RabbitConnectionFactoryBean
and Configuring SSL。
The RabbitConnectionFactoryBean
now uses TLS 1.2 by default when SSL is enabled.
See RabbitConnectionFactoryBean
and Configuring SSL for more information.
New MessagePostProcessor Classes
当消息内容编码设置为 deflate
时,已添加类 DeflaterPostProcessor
和 InflaterPostProcessor
来分别支持压缩和解压缩。
Classes DeflaterPostProcessor
and InflaterPostProcessor
were added to support compression and decompression, respectively, when the message content-encoding is set to deflate
.
Other Changes
现在,Declarables
对象(用于声明多个队列、交换和绑定)对每种类型具有筛选的 getter。有关详细信息,请参见 Declaring Collections of Exchanges, Queues, and Bindings。
The Declarables
object (for declaring multiple queues, exchanges, bindings) now has a filtered getter for each type.
See Declaring Collections of Exchanges, Queues, and Bindings for more information.
您现在可以在 RabbitAdmin
处理声明之前自定义每个 Declarable
Bean。有关详细信息,请参见 Automatic Declaration of Exchanges, Queues, and Bindings。
You can now customize each Declarable
bean before the RabbitAdmin
processes the declaration thereof.
See Automatic Declaration of Exchanges, Queues, and Bindings for more information.
已将 singleActiveConsumer()
添加到 QueueBuilder
中以设置 x-single-active-consumer
队列参数。有关详细信息,请参见 Builder API for Queues and Exchanges。
singleActiveConsumer()
has been added to the QueueBuilder
to set the x-single-active-consumer
queue argument.
See Builder API for Queues and Exchanges for more information.
现在使用 getName()
而不是 toString()
映射具有类型值 Class<?>
的出站标头。有关详细信息,请参见 Message Properties Converters。
Outbound headers with values of type Class<?>
are now mapped using getName()
instead of toString()
.
See Message Properties Converters for more information.
现在支持恢复失败的生产者创建的事务。有关详细信息,请参见 Retry with Batch Listeners。
Recovery of failed producer-created batches is now supported. See Retry with Batch Listeners for more information.