此版本仍在开发中,尚不被认为是稳定的。对于最新的稳定版本,请使用 Spring AMQP 3.2.6spring-doc.cadn.net.cn

自 1.3 以来 1.4 的变化

@RabbitListener注解

POJO 监听器可以使用@RabbitListener,由@EnableRabbit<rabbit:annotation-driven />. 此功能需要 Spring Framework 4.1。 有关更多信息,请参阅注释驱动的侦听器端点spring-doc.cadn.net.cn

RabbitMessagingTemplate添加

一个新的RabbitMessagingTemplate允许您通过使用spring-messaging Message实例。 在内部,它使用RabbitTemplate,您可以正常配置。 此功能需要 Spring Framework 4.1。 有关更多信息,请参阅消息传递集成spring-doc.cadn.net.cn

侦听器容器missingQueuesFatal属性

1.3.5 引入了missingQueuesFatal属性SimpleMessageListenerContainer. 这现在在侦听器容器命名空间元素上可用。 请参阅消息侦听器容器配置spring-doc.cadn.net.cn

兔子模板ConfirmCallback接口

confirm方法有一个额外的参数,称为cause. 如果可用,此参数包含否定确认 (nack) 的原因。 请参阅相关发布者确认和退货spring-doc.cadn.net.cn

RabbitConnectionFactoryBean添加

RabbitConnectionFactoryBean创建底层 RabbitMQConnectionFactoryCachingConnectionFactory. 这允许使用 Spring 的依赖注入配置 SSL 选项。 请参阅配置底层客户端连接工厂spring-doc.cadn.net.cn

CachingConnectionFactory

CachingConnectionFactory现在让connectionTimeout设置为命名空间中的属性或属性。 它在底层 RabbitMQ 上设置属性ConnectionFactory. 请参阅配置底层客户端连接工厂spring-doc.cadn.net.cn

日志附加器

日志返回org.springframework.amqp.rabbit.logback.AmqpAppender已被引入。 它提供了类似于org.springframework.amqp.rabbit.log4j.AmqpAppender. 有关更多信息,请参阅这些类的 JavaDoc。spring-doc.cadn.net.cn

日志4jAmqpAppender现在支持deliveryMode属性 (PERSISTENTNON_PERSISTENT违约:PERSISTENT). 以前,所有 log4j 消息都是PERSISTENT.spring-doc.cadn.net.cn

附加器还支持修改Message发送前 — 例如,允许添加自定义标头。 子类应该覆盖postProcessMessageBeforeSend().spring-doc.cadn.net.cn

侦听器队列

现在,默认情况下,侦听器容器在启动期间重新声明任何丢失的队列。 一个新的auto-declare属性已添加到<rabbit:listener-container>以防止这些重新声明。 看auto-delete队列.spring-doc.cadn.net.cn

RabbitTemplate:mandatoryconnectionFactorySelector表达 式

mandatoryExpression,sendConnectionFactorySelectorExpressionreceiveConnectionFactorySelectorExpressionSpEL 表达式属性已添加到RabbitTemplate. 这mandatoryExpression用于评估mandatoryReturnCallback正在使用中。 请参阅相关发布者确认和退货。 这sendConnectionFactorySelectorExpressionreceiveConnectionFactorySelectorExpressionAbstractRoutingConnectionFactory,以确定lookupKey对于目标ConnectionFactory在每个 AMQP 协议交互作的运行时。 请参阅布线连接工厂spring-doc.cadn.net.cn

侦听器和路由连接工厂

您可以配置SimpleMessageListenerContainer使用路由连接工厂,以启用基于队列名称的连接选择。 请参阅布线连接工厂spring-doc.cadn.net.cn

RabbitTemplate:RecoveryCallback选择

recoveryCallback属性已添加,可在retryTemplate.execute(). 请参阅添加重试功能spring-doc.cadn.net.cn

MessageConversionException改变

此异常现在是AmqpException. 考虑以下代码:spring-doc.cadn.net.cn

try {
    template.convertAndSend("thing1", "thing2", "cat");
}
catch (AmqpException e) {
	...
}
catch (MessageConversionException e) {
	...
}

第二个捕获块不再可访问,需要移动到捕获所有AmqpExceptioncatch 块。spring-doc.cadn.net.cn

RabbitMQ 3.4 兼容性

Spring AMQP 现在与 RabbitMQ 3.4 兼容,包括直接回复。 有关更多信息,请参阅兼容性RabbitMQ 直接回复spring-doc.cadn.net.cn

ContentTypeDelegatingMessageConverter添加

ContentTypeDelegatingMessageConverter已引入以选择MessageConverter使用,基于contentType属性中的MessageProperties. 有关详细信息,请参阅消息转换器spring-doc.cadn.net.cn