|
此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring AMQP 3.2.0! |
1.4 中自 1.3 以来的变化
@RabbitListener注解
POJO 侦听器可以用@RabbitListener,由@EnableRabbit或<rabbit:annotation-driven />.
此功能需要 Spring Framework 4.1。
有关更多信息,请参阅 Annotation-driven Listener Endpoints 。
RabbitMessagingTemplate添加
新的RabbitMessagingTemplate允许您使用spring-messaging Message实例。
在内部,它使用RabbitTemplate,您可以正常配置。
此功能需要 Spring Framework 4.1。
有关更多信息,请参阅消息收发集成。
侦听器容器missingQueuesFatal属性
1.3.5 引入了missingQueuesFatal属性SimpleMessageListenerContainer.
现在,这在侦听器容器命名空间元素上可用。
请参阅 消息侦听器容器配置。
RabbitTemplate (兔模板)ConfirmCallback接口
这confirmmethod 有一个名为cause.
如果可用,此参数包含否定确认 (nack) 的原因。
请参阅 相关发布者确认和返回。
RabbitConnectionFactoryBean添加
RabbitConnectionFactoryBean创建底层 RabbitMQConnectionFactory由CachingConnectionFactory.
这允许使用 Spring 的依赖项注入配置 SSL 选项。
请参阅配置底层客户端连接工厂。
用CachingConnectionFactory
这CachingConnectionFactory现在让connectionTimeout设置为命名空间中的属性或属性。
它在底层 RabbitMQ 上设置属性ConnectionFactory.
请参阅配置底层客户端连接工厂。
Log Appender
Logback 软件org.springframework.amqp.rabbit.logback.AmqpAppender已引入。
它提供类似于org.springframework.amqp.rabbit.log4j.AmqpAppender.
有关更多信息,请参阅这些类的 JavaDoc。
The Log4jAmqpAppender现在支持deliveryMode属性 (PERSISTENT或NON_PERSISTENT违约:PERSISTENT).
以前,所有 log4j 消息都是PERSISTENT.
appender 还支持修改Messagebefore sending — 例如,允许添加自定义标头。
子类应覆盖postProcessMessageBeforeSend().
侦听器队列
现在,默认情况下,侦听器容器会在启动期间重新声明任何缺失的队列。
新的auto-declare属性已添加到<rabbit:listener-container>来防止这些重新声明。
看auto-delete队列.
RabbitTemplate:mandatory和connectionFactorySelector表达 式
这mandatoryExpression,sendConnectionFactorySelectorExpression和receiveConnectionFactorySelectorExpressionSpEL 表达式的属性已添加到RabbitTemplate.
这mandatoryExpression用于评估mandatoryboolean 值,当ReturnCallback正在使用中。
请参阅 相关发布者确认和返回。
这sendConnectionFactorySelectorExpression和receiveConnectionFactorySelectorExpression在AbstractRoutingConnectionFactory,以确定lookupKey对于目标ConnectionFactory在每个 AMQP 协议交互作的运行时。
请参阅 Routing Connection Factory。
侦听器和路由连接工厂
您可以配置SimpleMessageListenerContainer使用路由连接工厂,以启用基于队列名称的连接选择。
请参阅 Routing Connection Factory。
RabbitTemplate:RecoveryCallback选择
这recoveryCallback属性,以便在retryTemplate.execute().
请参阅添加重试功能。
MessageConversionException改变
此异常现在是AmqpException.
请考虑以下代码:
try {
template.convertAndSend("thing1", "thing2", "cat");
}
catch (AmqpException e) {
...
}
catch (MessageConversionException e) {
...
}
第二个 catch 块不再可访问,需要移动到 catch-all 上方AmqpExceptioncatch 块。
RabbitMQ 3.4 兼容性
Spring AMQP 现在与 RabbitMQ 3.4 兼容,包括直接回复。 有关更多信息,请参阅兼容性和 RabbitMQ Direct 回复。
ContentTypeDelegatingMessageConverter添加
这ContentTypeDelegatingMessageConverter来选择MessageConverter使用,基于contentType属性在MessageProperties.
有关更多信息,请参阅 消息转换器 。