qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Qpid > Cheat Sheet for configuring Queue Options
Date Mon, 02 Nov 2009 13:13:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=qpid&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/qpid/Cheat+Sheet+for+configuring+Queue+Options">Cheat
Sheet for configuring Queue Options</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~cctrieloff">Carl
Trieloff</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h2><a name="CheatSheetforconfiguringQueueOptions-ConfiguringQueueOptions"></a>Configuring
Queue Options</h2>

<p>The C++ Broker M4 or later supports the following additional Queue constraints.</p>

<div>
<ul>
    <li><a href='#CheatSheetforconfiguringQueueOptions-ConfiguringQueueOptions'>Configuring
Queue Options</a></li>
<ul>
    <li><a href='#CheatSheetforconfiguringQueueOptions-ApplyingQueueSizingConstraints'>Applying
Queue Sizing Constraints</a></li>
    <li><a href='#CheatSheetforconfiguringQueueOptions-ChangingtheQueueorderingBehaviors%28FIFO%2FLVQ%29'>Changing
the Queue ordering Behaviors (FIFO/LVQ)</a></li>
    <li><a href='#CheatSheetforconfiguringQueueOptions-Settingadditionalbehaviors'>Setting
additional behaviors</a></li>
<ul>
    <li><a href='#CheatSheetforconfiguringQueueOptions-PersistLastNode'>Persist
Last Node</a></li>
    <li><a href='#CheatSheetforconfiguringQueueOptions-Queueeventgeneration'>Queue
event generation</a></li>
</ul>
    <li><a href='#CheatSheetforconfiguringQueueOptions-OtherClients'>Other Clients</a></li>
</ul>
</ul></div>

<h3><a name="CheatSheetforconfiguringQueueOptions-ApplyingQueueSizingConstraints"></a>Applying
Queue Sizing Constraints</h3>

<p>This allows to specify how to size a queue and what to do when the sizing constraints
have been reached. The queue size  can be limited by the number messages (message depth) or
byte depth on the queue.</p>

<p>Once the Queue meets/ exceeds these constraints the follow policies can be applied</p>

<ul>
	<li>REJECT - Reject the published message</li>
	<li>FLOW_TO_DISK - Flow the messages to disk, to preserve memory</li>
	<li>RING - start overwriting messages in a ring based on sizing. If head meets tail,
advance head</li>
	<li>RING_STRICT - start overwriting messages in a ring based on sizing. If head meets
tail, AND the consumer has the tail message acquired it will reject</li>
</ul>


<p>Examples:</p>

<p>Create a queue an auto delete queue that will support 100 000 bytes, and then REJECT</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
#include <span class="code-quote">"qpid/client/QueueOptions.h"</span>

    QueueOptions qo;
    qo.setSizePolicy(REJECT,100000,0);

    session.queueDeclare(arg::queue=queue, arg::autoDelete=<span class="code-keyword">true</span>,
arg::arguments=qo);
</pre>
</div></div>

<p>Create a queue that will support 1000 messages into a RING buffer</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
#include <span class="code-quote">"qpid/client/QueueOptions.h"</span>

    QueueOptions qo;
    qo.setSizePolicy(RING,0,1000);

    session.queueDeclare(arg::queue=queue, arg::arguments=qo);
</pre>
</div></div>

<h3><a name="CheatSheetforconfiguringQueueOptions-ChangingtheQueueorderingBehaviors%28FIFO%2FLVQ%29"></a>Changing
the Queue ordering Behaviors (FIFO/LVQ)</h3>

<p>The default ordering in a queue in Qpid is FIFO. However additional ordering semantics
can be used namely LVQ (Last Value Queue). Last Value Queue is define as follows.</p>

<p>If I publish symbols RHT, IBM, JAVA, MSFT, and then publish RHT before the consumer
is able to consume RHT, that message will be over written in the queue and the consumer will
receive the last published value for RHT.</p>

<p>Example:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
#include <span class="code-quote">"qpid/client/QueueOptions.h"</span>

    QueueOptions qo;
    qo.setOrdering(LVQ);

    session.queueDeclare(arg::queue=queue, arg::arguments=qo);

    .....
    string key;
    qo.getLVQKey(key);

    ....
    <span class="code-keyword">for</span> each message, set the into application
headers before transfer
    message.getHeaders().setString(key,<span class="code-quote">"RHT"</span>);
    
</pre>
</div></div>

<p>Notes:</p>
<ul>
	<li>Messages that are dequeued and the re-queued will have the following exceptions.
a.) if a new message has been queued with the same key, the re-queue from the consumer, will
combine these two messages. b.) If an update happens for a message of the same key, after
the re-queue, it will not update the re-queued message.  This is done to protect a client
from being able to adversely manipulate the queue.</li>
	<li>Acquire: When a message is acquired from the queue, no matter it's position, it
will behave the same as a dequeue</li>
	<li>LVQ does not support durable messages. If the queue or messages are declared durable
on an LVQ, the durability will be ignored.</li>
</ul>


<p>A fully worked <a href="/confluence/display/qpid/LVQ+Example" title="LVQ Example">LVQ
Example</a> can be found here</p>


<h3><a name="CheatSheetforconfiguringQueueOptions-Settingadditionalbehaviors"></a>Setting
additional behaviors </h3>

<h4><a name="CheatSheetforconfiguringQueueOptions-PersistLastNode"></a>Persist
Last Node</h4>

<p>This option is used in conjunction with clustering. It allows for a queue configured
with this option to persist transient messages if the cluster fails down to the last node.
If additional nodes in the cluster are restored it will stop persisting transient messages.</p>

<p>Note </p>
<ul>
	<li>if a cluster is started with only one active node, this mode will not be triggered.
It is only triggered the first time the cluster fails down to 1 node.</li>
	<li>The queue MUST be configured durable</li>
</ul>


<p>Example:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
#include <span class="code-quote">"qpid/client/QueueOptions.h"</span>

    QueueOptions qo;
    qo.clearPersistLastNode();

    session.queueDeclare(arg::queue=queue, arg::durable=<span class="code-keyword">true</span>,
arg::arguments=qo);
</pre>
</div></div>

<h4><a name="CheatSheetforconfiguringQueueOptions-Queueeventgeneration"></a>Queue
event generation</h4>

<p>This option is used to determine whether enqueue/dequeue events representing changes
made to queue state are generated. These events can then be processed by plugins such as that
used for <a href="/confluence/display/qpid/queue+state+replication" title="queue state
replication">queue state replication</a>.</p>

<p>Example:</p>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
#include <span class="code-quote">"qpid/client/QueueOptions.h"</span>

    QueueOptions options;
    options.enableQueueEvents(1);
    session.queueDeclare(arg::queue=<span class="code-quote">"my-queue"</span>,
arg::arguments=options);
</pre>
</div></div>

<p>The boolean option indicates whether only enqueue events should be generated. The
key set by this is 'qpid.queue_event_generation' and the value is and integer value of 1 (to
replicate only enqueue events) or 2 (to replicate both enqueue and dequeue events).</p>

<h3><a name="CheatSheetforconfiguringQueueOptions-OtherClients"></a>Other
Clients</h3>

<p>Note that these options can be set from any client. QueueOptions just correctly formats
the arguments passed to the QueueDeclare() method.</p>


     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/qpid/Cheat+Sheet+for+configuring+Queue+Options">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=98678&revisedVersion=14&originalVersion=13">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/qpid/Cheat+Sheet+for+configuring+Queue+Options?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message