Changes in 1.4 Since 1.3
-
POJO 侦听器可使用 @RabbitListener 进行注解。
-
添加了 RabbitMessagingTemplate,允许使用 Message 对象与 RabbitMQ 交互。
-
侦听器容器增加了 missingQueuesFatal 属性。
-
RabbitTemplate ConfirmCallback 接口添加了原因参数。
-
添加了 RabbitConnectionFactoryBean,允许配置 SSL 选项。
-
CachingConnectionFactory 可以配置 connectionTimeout。
-
引入了 AmqpAppender,提供记录选项。
-
侦听器容器默认重新声明缺少的队列。
-
RabbitTemplate 添加了 mandatoryExpression、sendConnectionFactorySelectorExpression 和 receiveConnectionFactorySelectorExpression 表达式。
-
使用路由连接工厂配置侦听器容器以启用队列名称连接选择。
-
RabbitTemplate 添加了 recoveryCallback 选项。
-
MessageConversionException 现在是 AmqpException 的子类。
-
Spring AMQP 与 RabbitMQ 3.4 兼容。
-
添加了 ContentTypeDelegatingMessageConverter 以基于内容类型选择消息转换器。
@RabbitListener
Annotation
POJO 侦听器可以使用 @RabbitListener
进行注释,并由 @EnableRabbit
或 <rabbit:annotation-driven />
启用。此功能需要 Spring Framework 4.1。有关更多信息,请参阅 Annotation-driven Listener Endpoints。
POJO listeners can be annotated with @RabbitListener
, enabled by @EnableRabbit
or <rabbit:annotation-driven />
.
Spring Framework 4.1 is required for this feature.
See Annotation-driven Listener Endpoints for more information.
RabbitMessagingTemplate
Added
一个新的 RabbitMessagingTemplate`可以让您通过使用 `spring-messaging``Message`实例与 RabbitMQ 交互。在内部,它使用 `RabbitTemplate
,您可以照常进行配置。此功能需要 Spring Framework 4.1。有关更多信息,请参见 Messaging Integration。
A new RabbitMessagingTemplate
lets you interact with RabbitMQ by using spring-messaging
Message
instances.
Internally, it uses the RabbitTemplate
, which you can configure as normal.
Spring Framework 4.1 is required for this feature.
See Messaging Integration for more information.
Listener Container missingQueuesFatal
Attribute
1.3.5 在 SimpleMessageListenerContainer
上引入了 missingQueuesFatal
属性。现在可以在侦听器容器命名空间元素上使用它。有关更多信息,请参阅 Message Listener Container Configuration。
1.3.5 introduced the missingQueuesFatal
property on the SimpleMessageListenerContainer
.
This is now available on the listener container namespace element.
See Message Listener Container Configuration.
RabbitTemplate ConfirmCallback
Interface
此接口上的 `confirm`方法有一个称为 `cause`的附加参数。此参数在可用时包含不确认 (nack) 的原因。参见 Correlated Publisher Confirms and Returns。
The confirm
method on this interface has an additional parameter called cause
.
When available, this parameter contains the reason for a negative acknowledgement (nack).
See Correlated Publisher Confirms and Returns.
RabbitConnectionFactoryBean
Added
RabbitConnectionFactoryBean
创建由 CachingConnectionFactory
使用的 RabbitMQ 底层 ConnectionFactory
。这允许使用 Spring 的依赖注入配置 SSL 选项。请参阅 [connection-factory]。
RabbitConnectionFactoryBean
creates the underlying RabbitMQ ConnectionFactory
used by the CachingConnectionFactory
.
This enables configuration of SSL options using Spring’s dependency injection.
See [connection-factory].
Using CachingConnectionFactory
CachingConnectionFactory
现可将 connectionTimeout
设置为命名空间中的属性或特性。它将在底层的 RabbitMQ ConnectionFactory
上设置该属性。请参阅 [connection-factory]。
The CachingConnectionFactory
now lets the connectionTimeout
be set as a property or as an attribute in the namespace.
It sets the property on the underlying RabbitMQ ConnectionFactory
.
See [connection-factory].
Log Appender
推出了 Logback org.springframework.amqp.rabbit.logback.AmqpAppender
。它提供了类似于 org.springframework.amqp.rabbit.log4j.AmqpAppender
的选项。有关更多信息,请参阅这些类的 JavaDoc。
The Logback org.springframework.amqp.rabbit.logback.AmqpAppender
has been introduced.
It provides options similar to org.springframework.amqp.rabbit.log4j.AmqpAppender
.
For more information, see the JavaDoc of these classes.
Log4j AmqpAppender
现在支持 deliveryMode
属性(PERSISTENT
或 NON_PERSISTENT
,默认为 PERSISTENT
)。以前,所有 log4j 消息均为 PERSISTENT
。
The Log4j AmqpAppender
now supports the deliveryMode
property (PERSISTENT
or NON_PERSISTENT
, default: PERSISTENT
).
Previously, all log4j messages were PERSISTENT
.
此附加程序还支持在发送前修改消息,例如允许添加自定义头。子类应该重写 postProcessMessageBeforeSend()
。
The appender also supports modification of the Message
before sending — allowing, for example, the addition of custom headers.
Subclasses should override the postProcessMessageBeforeSend()
.
Listener Queues
现在,侦听器容器在启动期间默认重新声明所有丢失的队列。<rabbit:listener-container>`中添加了一个新的 `auto-declare`属性以阻止这些重新声明。参见 `auto-delete
Queues。
The listener container now, by default, redeclares any missing queues during startup.
A new auto-declare
attribute has been added to the <rabbit:listener-container>
to prevent these re-declarations.
See auto-delete
Queues.
RabbitTemplate
: mandatory
and connectionFactorySelector
Expressions
mandatoryExpression
、sendConnectionFactorySelectorExpression`和`receiveConnectionFactorySelectorExpression`SpEL表达式属性已添加到`RabbitTemplate
。当`ReturnCallback`正在使用时,mandatoryExpression`用于针对每个请求消息求出`mandatory`布尔值。请参阅Correlated Publisher Confirms and Returns。当提供`AbstractRoutingConnectionFactory`时,正在使用`sendConnectionFactorySelectorExpression`和`receiveConnectionFactorySelectorExpression`确定在每个AMQP协议交互操作的运行时目标`ConnectionFactory`的`lookupKey
。请参阅[routing-connection-factory]。
The mandatoryExpression
, sendConnectionFactorySelectorExpression
, and receiveConnectionFactorySelectorExpression
SpEL Expression`s properties have been added to RabbitTemplate
.
The mandatoryExpression
is used to evaluate a mandatory
boolean value against each request message when a ReturnCallback
is in use.
See Correlated Publisher Confirms and Returns.
The sendConnectionFactorySelectorExpression
and receiveConnectionFactorySelectorExpression
are used when an AbstractRoutingConnectionFactory
is provided, to determine the lookupKey
for the target ConnectionFactory
at runtime on each AMQP protocol interaction operation.
See [routing-connection-factory].
Listeners and the Routing Connection Factory
你可以使用路由连接工厂配置 SimpleMessageListenerContainer
,以基于队列名称启用连接选择。请参阅 [routing-connection-factory]。
You can configure a SimpleMessageListenerContainer
with a routing connection factory to enable connection selection based on the queue names.
See [routing-connection-factory].
RabbitTemplate
: RecoveryCallback
Option
已添加 `recoveryCallback`属性以供在 `retryTemplate.execute()`中使用。参见 Adding Retry Capabilities。
The recoveryCallback
property has been added for use in the retryTemplate.execute()
.
See Adding Retry Capabilities.
MessageConversionException
Change
此异常现在是 AmqpException
的子类。考虑以下代码:
This exception is now a subclass of AmqpException
.
Consider the following code:
try {
template.convertAndSend("thing1", "thing2", "cat");
}
catch (AmqpException e) {
...
}
catch (MessageConversionException e) {
...
}
第二个 catch 块现在无法访问,需要移动到 catch-all AmqpException
catch 块之上。
The second catch block is no longer reachable and needs to be moved above the catch-all AmqpException
catch block.
RabbitMQ 3.4 Compatibility
Spring AMQP 现在与 RabbitMQ 3.4 兼容,包括直接回复。有关更多信息,请参见 Compatibility和 RabbitMQ Direct reply-to。
Spring AMQP is now compatible with the RabbitMQ 3.4, including direct reply-to. See Compatibility and RabbitMQ Direct reply-to for more information.
ContentTypeDelegatingMessageConverter
Added
已引入 ContentTypeDelegatingMessageConverter
以根据 MessageProperties
中的 contentType
属性选择要使用的 MessageConverter
。有关更多信息,请参阅 Message Converters。
The ContentTypeDelegatingMessageConverter
has been introduced to select the MessageConverter
to use, based on the contentType
property in the MessageProperties
.
See Message Converters for more information.