rabbitmq doc 地址: http://www.rabbitmq.com/extensions.html
1、x-priority: basic.consume方法参数(int)。用于设定consumer的优先级,数字越大,优先级越高,默认是0,可以设置负数。
2、alternate-exchange: exchange.declare方法参数(str,AE的名称)。当一个消息不能被route的时候,如果exchange设定了AE,则消息会被投递到AE。如果存在AE链,则会按此继续投递,直到消息被route或AE链结束或遇到已经尝试route过消息的AE。
3、x-message-ttl: queue.declare方法参数(毫秒,非负整数),用于限定queue上消息的生存时间,可配合DLX。
消息可通过设置expiration控制自己的过期时间。queue设定的ttl和消息自己的ttl由两者的小值生效。
4、x-expires:queue.declare方法参数(毫秒,正整数),用于限定queue自身的生存时间。
5、x-dead-letter-exchange: queue.declare方法参数(str,DLX的名称)。
6、x-dead-letter-routing-key: queue.declare方法参数(str,DLX的route)。不设定则使用message自身的route。
DLX的route需要confirm,如果server端宕机但没清理数据,一个dead-letter-message有存在两条的可能(一条在original queue, 一条在DLX target queue).
DLX可能会形成一个循环,当message在整个循环中都没有rejection时,其在routed到同一个queue两次时被丢弃。
Dead-lettering a message modifies its headers:
the exchange name is replaced with that of the latest dead-letter exchange,
the routing key may be replaced with that specified in a queue performing dead lettering,
if the above happens, the CC header will also be removed, and
the BCC header will be removed as per Sender-selected distribution.
The dead-lettering process adds an array to the header of each dead-lettered message named x-death.
This array contains an entry for each dead lettering event, identified by a pair of {queue, reason}.
Each such entry is a table that consists of several fields:
queue - the name of the queue the message was in before it was dead-lettered,
reason - see below,
time - the date and time the message was dead lettered as a 64-bit AMQP format timestamp,
exchange - the exchange the message was published to (note that this will be a dead letter exchange if the message is dead lettered multiple times),
routing-keys - the routing keys (including CC keys but excluding BCC ones) the message was published with,
count - how many times this message was dead-lettered in this queue for this reason, and
original-expiration (if the message was dead-letterered due to per-message TTL) - the original expiration property of the message. The expiration property is removed from the message on dead-lettering in order to prevent it from expiring again in any queues it is routed to.
In case x-death already contains an entry with the same queue and dead lettering reason, its count field will be incremented.
The reason is a name describing why the message was dead-lettered and is one of the following:
rejected - the message was rejected with requeue=false,
expired - the TTL of the message expired; or
maxlen - the maximum allowed queue length was exceeded.
Note that the array is sorted most-recent-first, so the most recent dead-lettering will be recorded in the first entry.
7、x-max-length: queue.declare方法参数(非负整数)。用于限制queue的最大ready消息总数。
8、x-max-length-bytes: queue.declare方法参数(非负整数)。用于限制queue的最大ready消息的body总字节数。
两种限制可同时设置,最先到达的限制条件将被生效。
9、x-max-priority: queue.declare方法参数(int)。rabbitmq3.5.0版本后支持优先队列。由于优先队列是一种特殊的持久化方式,使得优先队列只能通过arguments的方式声明,且声明后不可改变其支持的priorities。
对每一个优先队列的每一个优先级在内存、磁盘都有单独的开销;及额外的CPU开销,特别是在consume的时候。
通过在message的basic.properties中指明priority(unsigned byte, 0-255),较大的数对应较高的优先级。若未指明message的priority则priority默认为0。
若message的priority大于queue的maximum priority则priority被认为是maximum priority。
对于优先队列,有如下注意事项:
由于默认情况下consumer的预取消息,消息可能会立即被投递给consumer,而导致优先级关系不能被处理。因而需要在ack模式下设定basic.qos的prefetch_count,限制消息的投递。
如果优先队列设置了message-ttl,则由于server的ttl清理是从head方向检测处理的,低优先级的过期消息可能会一直存在而无法被清理,且会被统计(如ready的消息数,但不会被deliver)。
如果优先队列设置了max-length,则由于server从head方向drop消息以使限制生效,使得高优先级的消息被drop掉,而预留位置给低优先级的消息,可能和使用优先队列的初衷背离。
10、user-id:channel.basicPublish 中指定的BasicProperties字段。用于验证publisher。其值应与建立connection的user名称一致。
若需要伪造验证,user-id可使用 impersonator tag,但不能使用 administrator tag。
federation 从upstream收到消息时会丢弃user-id,除非在upstream设置trust-user-id 属性。
11、authentication_failure_close: broker capability. 用于client区分鉴权错误还是网络错误,在AMQP091中要求鉴权失败则broker关闭连接,以至于client无法区分于实际的网络连接错误。
当开启这个设置时,broker在鉴权失败后向客户端发送connection.close的命令并附带ACCESS_REFUSED的原因标识。