A Consumer is created when an AMQP connection wishes to receive messages from a message source (such as a Queue). The standard behaviours of consumers are defined by the respective AMQP specification, however in addition to the standard behaviours a number of Qpid specific enhancements are available
By default, when there are multiple competing consumers attached to the same message source, the Broker attempts to distribute messages from the queue in a "fair" manner. Some use cases require allocation of messages to consumers to be based on the "priority" of the consumer. Where there are multiple consumers having differing priorities, the Broker will always attempt to deliver a message to a higher priority consumer before attempting delivery to a lower priority consumer. That is, a lower priority consumer will only receive a message if no higher priority consumers currently have credit available to consume the message, or those consumers have declined to accept the message (for instance because it does not meet the criteria of any selectors associated with the consumer).
Where a consumer is created with no explicit priority provided, the consumer is given the highest possible priority.
In AMQP 0-9 and 0-9-1 the priority of the consumer can be set by adding an entry into the table provided as the
arguments
field (known as the filter
field on AMQP 0-9) of the
basic.consume
method. The key for the entry must be the literal short string
x-priority
, and the value of the entry must be an integral number in the range
-231 to 231-1.
In AMQP 0-10 the priority of the consumer can be set in the map provided as the arguments
field of the message.subscribe
method. The key for the entry must be the literal string
x-priority
, and the value of the entry must be an integral number in the range
-231 to 231-1.
In AMQP 1.0 the priority of the consumer is set in the properties
map of the
attach
frame where the broker side of the link represents the sending side of the link.
The key for the entry must be the literal string priority
, and the value of the entry must
be an integral number in the range -231 to 231-1.
When using the Qpid JMS client for AMQP 0-9/0-9-1/0-10 the consumer priority can be set in the address being used for the Destination object.
Table 9.1. Setting the consumer priority
Syntax | Example |
---|---|
Addressing | myqueue : { link : { x-subscribe: { arguments : { x-priority : '10' } } } } |
Binding URL | direct://amq.direct/myqueue/myqueue?x-qpid-replay-priority='10' |
Apache Qpid, Messaging built on AMQP; Copyright © 2015 The Apache Software Foundation; Licensed under the Apache License, Version 2.0; Apache Qpid, Qpid, Qpid Proton, Proton, Apache, the Apache feather logo, and the Apache Qpid project logo are trademarks of The Apache Software Foundation; All other marks mentioned may be trademarks or registered trademarks of their respective owners