Changes in 1.5 Since 1.4
-
弃用spring-erlang jar,建议使用management-rest-api。
-
CachingConnectionFactory对空"addresses"属性的处理方式进行了更改。
-
添加了新的构造函数,允许使用URI配置代理连接。
-
引入了resetConnection()方法,用于重置连接。
-
侦听器容器队列声明行为的属性可配置。
-
RabbitGatewaySupport类已移动到新的软件包。
-
改进了DefaultMessagePropertiesConverter,允许配置转换为String的LongString的最大长度。
-
增强了@RabbitListener注解,支持queue binding规范和SpEL表达式。
-
可以通过Bean声明交换机、队列和绑定集合,并由RabbitAdmin自动声明。
-
RabbitTemplate支持在receive方法中进行阻塞。
-
引入RabbitManagementTemplate,用于通过REST API监视和配置RabbitMQ代理。
-
改进了@RabbitListener,支持类级别注解和多方法侦听器。
-
SimpleMessageListenerContainer增加了对BackOff支持。
spring-erlang
Is No Longer Supported
不再在发行版中包含 spring-erlang
jar。请改用 management-rest-api。
The spring-erlang
jar is no longer included in the distribution.
Use management-rest-api instead.
CachingConnectionFactory
Changes
Empty Addresses Property in CachingConnectionFactory
此前,如果连接工厂被配置为具有主机和端口但同时也为“addresses”提供了一个空字符串,则会忽略主机和端口。现在,一个空的“addresses”字符串被视为与“null”相同,并且使用了主机和端口。
Previously, if the connection factory was configured with a host and port but an empty String was also supplied for
addresses
, the host and port were ignored.
Now, an empty addresses
String is treated the same as a null
, and the host and port are used.
URI Constructor
CachingConnectionFactory
有一个额外的构造函数,带有 URI
参数,以配置代理连接。
The CachingConnectionFactory
has an additional constructor, with a URI
parameter, to configure the broker connection.
Connection Reset
已经添加了一个名为 resetConnection()
的新方法,用于允许用户重置连接(或连接)。例如,您可能会使用此方法在故障转移到辅助代理后重新连接到主代理。这*确实*影响正在进行的作业。现有的 destroy()
方法执行完全相同的操作,但新方法的名称不那么令人生畏。
A new method called resetConnection()
has been added to let users reset the connection (or connections).
You might use this, for example, to reconnect to the primary broker after failing over to the secondary broker.
This does impact in-process operations.
The existing destroy()
method does exactly the same, but the new method has a less daunting name.
Properties to Control Container Queue Declaration Behavior
当侦听器容器使用者启动时,他们尝试被动声明队列以确保它们在代理上可用。此前,如果这些声明失败(例如,因为队列不存在)或 HA 队列正在被移动,则重试逻辑固定在五秒间隔的三次重试尝试上。如果队列仍然不存在,则由 missingQueuesFatal
属性(默认值:true
)控制行为。此外,对于配置为从多个队列中侦听的容器,如果只有一部分队列可用,则使用者会以 60 秒的固定间隔重试丢失的队列。
When the listener container consumers start, they attempt to passively declare the queues to ensure they are available
on the broker.
Previously, if these declarations failed (for example, because the queues didn’t exist) or when an HA queue was being
moved, the retry logic was fixed at three retry attempts at five-second intervals.
If the queues still do not exist, the behavior is controlled by the missingQueuesFatal
property (default: true
).
Also, for containers configured to listen from multiple queues, if only a subset of queues are available, the consumer
retried the missing queues on a fixed interval of 60 seconds.
declarationRetries
、failedDeclarationRetryInterval
和 retryDeclarationInterval
属性现在可配置。请参阅 Message Listener Container Configuration 了解更多信息。
The declarationRetries
, failedDeclarationRetryInterval
, and retryDeclarationInterval
properties are now configurable.
See Message Listener Container Configuration for more information.
Class Package Change
RabbitGatewaySupport
类已从 o.s.amqp.rabbit.core.support
移到 o.s.amqp.rabbit.core
。
The RabbitGatewaySupport
class has been moved from o.s.amqp.rabbit.core.support
to o.s.amqp.rabbit.core
.
DefaultMessagePropertiesConverter
Changes
您现在可以配置 DefaultMessagePropertiesConverter
以确定转换为 String
而不是 DataInputStream
的 LongString
的最大长度。该转换器有一个替代构造函数,它将该值作为限制。此前,此限制以硬编码方式设置为 1024
字节。(1.4.4 中也可用)。
You can now configure the DefaultMessagePropertiesConverter
to
determine the maximum length of a LongString
that is converted
to a String
rather than to a DataInputStream
.
The converter has an alternative constructor that takes the value as a limit.
Previously, this limit was hard-coded at 1024
bytes.
(Also available in 1.4.4).
@RabbitListener
Improvements
@QueueBinding
for @RabbitListener
bindings
属性已添加到 @RabbitListener
注解中,作为与 queues
属性互斥的,以允许规范要由 RabbitAdmin
在代理上声明的 queue
、它的 exchange
和 binding
。
The bindings
attribute has been added to the @RabbitListener
annotation as mutually exclusive with the queues
attribute to allow the specification of the queue
, its exchange
, and binding
for declaration by a RabbitAdmin
on
the Broker.
SpEL in @SendTo
@RabbitListener
的默认回复地址(@SendTo
)现在可以是 SpEL 表达式。
The default reply address (@SendTo
) for a @RabbitListener
can now be a SpEL expression.
Multiple Queue Names through Properties
您现在可以使用 SpEL 和属性占位符的组合为侦听器指定多个队列。
You can now use a combination of SpEL and property placeholders to specify multiple queues for a listener.
请参阅 Annotation-driven Listener Endpoints 了解更多信息。
See Annotation-driven Listener Endpoints for more information.
Automatic Exchange, Queue, and Binding Declaration
您现在可以声明定义这些实体的集合的 Bean,且 RabbitAdmin
会在连接建立时将内容添加到新声明的实体列表中。有关详细信息,请参见 Declaring Collections of Exchanges, Queues, and Bindings。
You can now declare beans that define a collection of these entities, and the RabbitAdmin
adds the
contents to the list of entities that it declares when a connection is established.
See Declaring Collections of Exchanges, Queues, and Bindings for more information.
RabbitTemplate
Changes
reply-address
Added
reply-address
属性已被添加到 <rabbit-template>
组件作为替代 reply-queue
。请参阅 Request/Reply Messaging 了解更多信息。(在 1.4.4 中也可以在 RabbitTemplate
上使用设置器)。
The reply-address
attribute has been added to the <rabbit-template>
component as an alternative reply-queue
.
See Request/Reply Messaging for more information.
(Also available in 1.4.4 as a setter on the RabbitTemplate
).
Blocking receive
Methods
RabbitTemplate
现在支持 receive
和 convertAndReceive
方法中的阻塞。请参阅 Polling Consumer 了解更多信息。
The RabbitTemplate
now supports blocking in receive
and convertAndReceive
methods.
See Polling Consumer for more information.
Mandatory with sendAndReceive
Methods
在使用 sendAndReceive
和 convertSendAndReceive
方法时如果设置了 mandatory
标志,那么如果无法传递请求消息,则调用线程将抛出 AmqpMessageReturnedException
。有关详细信息,请参见 Reply Timeout。
When the mandatory
flag is set when using the sendAndReceive
and convertSendAndReceive
methods, the calling thread
throws an AmqpMessageReturnedException
if the request message cannot be delivered.
See Reply Timeout for more information.
Improper Reply Listener Configuration
当使用命名回复队列时,该框架会尝试验证回复侦听器容器的正确配置。
The framework tries to verify proper configuration of a reply listener container when using a named reply queue.
有关详细信息,请参见 Reply Listener Container。
See Reply Listener Container for more information.
RabbitManagementTemplate
Added
已引入 RabbitManagementTemplate
来通过其 management plugin 提供的 REST API 监视和配置 RabbitMQ 经纪人。请参阅 [management-rest-api] 了解更多信息。
The RabbitManagementTemplate
has been introduced to monitor and configure the RabbitMQ Broker by using the REST API provided by its management plugin.
See [management-rest-api] for more information.
Listener Container Bean Names (XML)
<listener-container/>
元素上的 id
属性已删除。从这个版本开始,<listener/>
子元素上的 id
单独用于命名为每个侦听器元素创建的侦听器容器 Bean。
The id
attribute on the <listener-container/>
element has been removed.
Starting with this release, the id
on the <listener/>
child element is used alone to name the listener container bean created for each listener element.
应用常规 Spring Bean 名称覆盖。如果解析到一个与现有 Bean 相同 id
的后续 <listener/>
,则新定义将覆盖现有定义。此前,Bean 名称是从 <listener-container/>
和 <listener/>
元素的 id
属性组合而成的。
Normal Spring bean name overrides are applied.
If a later <listener/>
is parsed with the same id
as an existing bean, the new definition overrides the existing one.
Previously, bean names were composed from the id
attributes of the <listener-container/>
and <listener/>
elements.
迁移到此版本时,如果 <listener-container/>
元素上有 id
属性,请将其删除,而对子 <listener/>
元素设置 id
。
When migrating to this release, if you have id
attributes on your <listener-container/>
elements, remove them and set the id
on the child <listener/>
element instead.
但是,为了支持将容器作为一组进行启动和停止,已添加新的 group
属性。当定义此属性时,此元素创建的容器将添加到名称与此相同、类型为 Collection<SimpleMessageListenerContainer>
的 Bean 中。您可以遍历此组来启动和停止容器。
However, to support starting and stopping containers as a group, a new group
attribute has been added.
When this attribute is defined, the containers created by this element are added to a bean with this name, of type Collection<SimpleMessageListenerContainer>
.
You can iterate over this group to start and stop containers.
Class-Level @RabbitListener
现在可以在类级别应用 @RabbitListener
注释。与新的 @RabbitHandler
方法注释结合使用时,您可以根据有效负载类型选择处理程序方法。请参阅 Multi-method Listeners 了解更多信息。
The @RabbitListener
annotation can now be applied at the class level.
Together with the new @RabbitHandler
method annotation, this lets you select the handler method based on payload type.
See Multi-method Listeners for more information.
SimpleMessageListenerContainer
: BackOff Support
现在可以通过 BackOff
实例向 SimpleMessageListenerContainer
提供 consumer
启动恢复。有关详细信息,请参阅 Message Listener Container Configuration。
The SimpleMessageListenerContainer
can now be supplied with a BackOff
instance for consumer
startup recovery.
See Message Listener Container Configuration for more information.
Channel Close Logging
已经引入了控制通道关闭日志级别的机制。请参阅 Channel Close Logging。
A mechanism to control the log levels of channel closure has been introduced. See Channel Close Logging.
Application Events
现在,当消费者失败时,SimpleMessageListenerContainer
将发出应用程序事件。有关详细信息,请参阅 Consumer Events。
The SimpleMessageListenerContainer
now emits application events when consumers fail.
See Consumer Events for more information.
Consumer Tag Configuration
以前,异步消费者的消费者标签是由代理生成的。在此版本中,现在可以向侦听器容器提供命名策略。请参阅 Consumer Tags。
Previously, the consumer tags for asynchronous consumers were generated by the broker. With this release, it is now possible to supply a naming strategy to the listener container. See Consumer Tags.
Using MessageListenerAdapter
MessageListenerAdapter
现在支持队列名称(或使用者标记)到方法名称的映射,以根据接收消息的队列确定要调用的委托方法。
The MessageListenerAdapter
now supports a map of queue names (or consumer tags) to method names, to determine
which delegate method to call based on the queue from which the message was received.
LocalizedQueueConnectionFactory
Added
LocalizedQueueConnectionFactory
是一个新的连接工厂,它连接到驻留镜像队列的群集中的节点。
LocalizedQueueConnectionFactory
is a new connection factory that connects to the node in a cluster where a mirrored queue actually resides.
Anonymous Queue Naming
从 1.5.3 版本开始,您现在可以控制如何生成 AnonymousQueue
名称。有关详细信息,请参见 AnonymousQueue
。
Starting with version 1.5.3, you can now control how AnonymousQueue
names are generated.
See AnonymousQueue
for more information.