Menu Search

14.8. Configuring Queues

To create a priority, sorted or LVQ queue within configuration, add the appropriate xml to the virtualhost.xml configuration file within the queues element.

14.8.1. Simple

For declaration of a simple queue define a queue entry in the virtual host configuration as in example below

Example 14.7. Configuring a simple queue

<queue>
    <name>my-simple-queue</name>
    <my-simple-queue>
        <exchange>amq.direct</exchange>
        <durable>true</durable>
    </my-simple-queue>
</queue>

14.8.2. Priority

To defining a priority queue, add a <priority>true</priority> element. By default the queue will have 10 distinct priorities.

Example 14.8. Configuring a priority queue

<queue>
    <name>myqueue</name>
    <myqueue>
        <exchange>amq.direct</exchange>
        <priority>true</priority>
    </myqueue>
</queue>

If you require fewer priorities, it is possible to specify a priorities element (whose value is a integer value between 2 and 10 inclusive) which will give the queue that number of distinct priorities. When messages are sent to that queue, their effective priority will be calculated by partitioning the priority space. If the number of effective priorities is 2, then messages with priority 0-4 are treated the same as "lower priority" and messages with priority 5-9 are treated equivalently as "higher priority".

Example 14.9. Configuring a priority queue with fewer priorities

<queue>
    <name>myqueue</name>
    <myqueue>
        <exchange>amq.direct</exchange>
        <priority>true</priority>
        <priorities>4</priorities>
    </myqueue>
</queue>

14.8.3. Sorted

To define a sorted queue, add a sortKey element. The value of the sortKey element defines the message property to use the value of when sorting the messages put onto the queue.

Example 14.10. Configuring a sorted queue

<queue>
    <name>myqueue</name>
    <myqueue>
        <exchange>amq.direct</exchange>
        <sortKey>message-property-to-sort-by</sortKey>
    </myqueue>
</queue>

14.8.4. LVQ

To define a LVQ, add a lvq element with the value true. Without any further configuration this will define an LVQ which uses the JMS message property qpid.LVQ_key as the key for replacement.

Example 14.11. Configuring a LVQ queue

<queue>
    <name>myqueue</name>
    <myqueue>
        <exchange>amq.direct</exchange>
        <lvq>true</lvq>
    </myqueue>
</queue>

If you wish to define your own property then you can do so using the lvqKey element.

Example 14.12. Configuring a LVQ queue with custom message property name

<queue>
    <name>myqueue</name>
    <myqueue>
        <exchange>amq.direct</exchange>
        <lvq>true</lvq>
        <lvqKey>ISIN</lvqKey>
    </myqueue>
</queue>

14.8.5. Configuring queue with arguments

Queue arguments can be configured in virtual host configuration file. An element argument is used to specify a queue argument as a name-value pair separated with equal character. Any number of queue arguments can be provided for a queue in their own argument elements.

The following example demonstrates how to configure queue with two arguments.

Example 14.13. Setting arbitrary queue arguments

<queue>
    <name>myQueue</name>
    <myQueue>
        <argument>qpid.group_header_key=JMSXgroupID</argument>
        <argument>qpid.shared_msg_group=1</argument>
    </myQueue>
</queue>