Publisher Confirms and Returns(spring amqp中文翻译)

来源:互联网 发布:小猪微电商系统源码 编辑:程序博客网 时间:2024/06/01 08:47

Publisher Confirms and Returns

The RabbitTemplate implementation of AmqpTemplate supports Publisher Confirms and Returns.

rabbittemplate实现了amqptemplate接口,支持Publisher Confirms and Returns

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

For returned messages,

the template’s mandatory property must be set to true, or the mandatory-expression must evaluate to true for a particular message. 

模板的mandatory属性必须设置为true,或mandatory-expression必须对一个特定的消息评估为true。


This feature requires a CachingConnectionFactory that has its publisherReturns property set to true (see the section called “Publisher Confirms and Returns”). 

该特性需要将CachingConnectionFactory的publisherReturns属性设置为true。

Returns are sent to to the client by it registering a RabbitTemplate.ReturnCallback by callingsetReturnCallback(ReturnCallback callback)

Returns被  调用setReturnCallback ReturnCallback(ReturnCallback callback),注册RabbitTemplate.ReturnCallback的客户端

The callback must implement this method:

void returnedMessage(Message message, int replyCode, String replyText,          String exchange, String routingKey);

Only one ReturnCallback is supported by each RabbitTemplate. See also the section called “Reply Timeout”.

一个RabbitTemplate仅支持一个ReturnCallback。

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


For Publisher Confirms (aka Publisher Acknowledgements),

 the template requires a CachingConnectionFactory that has its publisherConfirms property set to true. 

template需要将CachingConnectionFactory的publisherConfirms属性设置为true。

Confirms are sent to to the client by it registering a RabbitTemplate.ConfirmCallback by callingsetConfirmCallback(ConfirmCallback callback)


The callback must implement this method:

void confirm(CorrelationData correlationData, boolean ack, String cause);

The CorrelationData is an object supplied by the client when sending the original message. 

CorrelationData是一个客户端提供的原始消息的对象。

The ack is true for an ack and false for a nack.

ack是true返回ack,是false返回nack

 For nack s, the cause may contain a reason for the nack, if it is available when the nack is generated. 

当nack生成时,cause参数有效,它包含一个nack的原因。

An example is when sending a message to a non-existent exchange. In that case the broker closes the channel; the reason for the closure is included in the causecause was added in version 1.4.

例如,当发送一个消息到不存在的exchange时,broker关闭channel;这个关闭的原因则放在cause中。

Only one ConfirmCallback is supported by a RabbitTemplate.

一个RabbitTemplate仅支持一个ConfirmCallback。



原文:http://docs.spring.io/spring-amqp/docs/1.6.1.RELEASE/reference/html/_reference.html#template-confirms

0 0
原创粉丝点击