summaryrefslogtreecommitdiff
path: root/qpid/doc/book/src/Cheat-Sheet-for-configuring-Queue-Options.xml
blob: d50948e0ccbeaa99d4a563cc755dab2762964b3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?xml version="1.0" encoding="utf-8"?>

<!--
 
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at
 
   http://www.apache.org/licenses/LICENSE-2.0
 
 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
 
-->

<section><title>
      Cheat Sheet for configuring Queue Options
    </title>

    <section role="h2" id="CheatSheetforconfiguringQueueOptions-ConfiguringQueueOptions"><title>
            Configuring
            Queue Options
          </title>

	  <para>
            The C++ Broker M4 or later supports the following additional
            Queue constraints.
          </para>
            <itemizedlist>
              <listitem><para>
                <xref linkend="CheatSheetforconfiguringQueueOptions-ConfiguringQueueOptions"/>
              </para></listitem>
              <listitem><para>
                <itemizedlist>
                  <listitem><para>
                    <xref linkend="CheatSheetforconfiguringQueueOptions-ApplyingQueueSizingConstraints"/>
                  </para></listitem>
                  <listitem><para>
                    <xref linkend="CheatSheetforconfiguringQueueOptions-ChangingtheQueueorderingBehaviors-28FIFO-2FLVQ-29"/>
                  </para></listitem>
                  <listitem><para>
                    <xref linkend="CheatSheetforconfiguringQueueOptions-Settingadditionalbehaviors"/>
                  </para></listitem>
                  <listitem><para>
                    <itemizedlist>
                      <listitem><para>
                        <xref linkend="CheatSheetforconfiguringQueueOptions-PersistLastNode"/>
                      </para></listitem>
                      <listitem><para>
                        <xref linkend="CheatSheetforconfiguringQueueOptions-Queueeventgeneration"/>
                      </para></listitem>
                    </itemizedlist>
                  </para></listitem>
                  <listitem><para>
                    <xref linkend="CheatSheetforconfiguringQueueOptions-OtherClients"/>
                  </para></listitem>
                </itemizedlist>
              </para></listitem>
            </itemizedlist>

	  <para>
            The 0.10 C++ Broker supports the following additional Queue configuration options:
          </para>
          <itemizedlist>
            <listitem><para>
              <xref linkend="producer-flow-control"/>
            </para></listitem>
          </itemizedlist>

          <section role="h3" id="CheatSheetforconfiguringQueueOptions-ApplyingQueueSizingConstraints"><title>
            Applying Queue Sizing Constraints
          </title>

	  <para>
            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.
          </para><para>
            Once the Queue meets/ exceeds these constraints the follow
            policies can be applied
          </para><itemizedlist>
            <listitem><para>REJECT - Reject the published message
            </para></listitem>
            <listitem><para>FLOW_TO_DISK - Flow the messages to disk, to preserve memory
            </para></listitem>
            <listitem><para>RING - start overwriting messages in a ring based on sizing.
            If head meets tail, advance head
            </para></listitem>
            <listitem><para>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
            </para></listitem>
          </itemizedlist><para>
            Examples:
          </para><para>
            Create a queue an auto delete queue that will support 100 000
            bytes, and then REJECT
          </para>
            <programlisting>
#include "qpid/client/QueueOptions.h"

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

    session.queueDeclare(arg::queue=queue, arg::autoDelete=true, arg::arguments=qo);
</programlisting>
          <para>
            Create a queue that will support 1000 messages into a RING buffer
          </para>
            <programlisting>
#include "qpid/client/QueueOptions.h"

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

    session.queueDeclare(arg::queue=queue, arg::arguments=qo);
</programlisting>
	  <!--h3--></section>
          <section role="h3" id="CheatSheetforconfiguringQueueOptions-ChangingtheQueueorderingBehaviors-28FIFO-2FLVQ-29"><title>
            Changing the Queue ordering Behaviors (FIFO/LVQ)
          </title>
          <para>
            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.
          </para><para>
            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.
          </para><para>
            Example:
          </para>
            <programlisting>
#include "qpid/client/QueueOptions.h"

    QueueOptions qo;
    qo.setOrdering(LVQ);

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

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

    ....
    for each message, set the into application headers before transfer
    message.getHeaders().setString(key,"RHT");
    
</programlisting>
          <para>
            Notes:
          </para><itemizedlist>
            <listitem><para>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.
            </para></listitem>
            <listitem><para>Acquire: When a message is acquired from the queue, no matter
            it's position, it will behave the same as a dequeue
            </para></listitem>
            <listitem><para>LVQ does not support durable messages. If the queue or
            messages are declared durable on an LVQ, the durability will be
            ignored.
            </para></listitem>
          </itemizedlist><para>
            A fully worked <xref linkend="LVQ-Examplesource"/> can be found here
          </para>
	  <!--h3--></section>
	  <section role="h3" id="CheatSheetforconfiguringQueueOptions-Settingadditionalbehaviors"><title>
            Setting additional behaviors
          </title>
          <section role="h4" id="CheatSheetforconfiguringQueueOptions-PersistLastNode"><title>
            Persist
            Last Node
          </title>
          <para>
            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.
          </para><para>
            Note
          </para><itemizedlist>
            <listitem><para>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.
            </para></listitem>
            <listitem><para>The queue MUST be configured durable
            </para></listitem>
          </itemizedlist><para>
            Example:
          </para>
            <programlisting>
#include "qpid/client/QueueOptions.h"

    QueueOptions qo;
    qo.clearPersistLastNode();

    session.queueDeclare(arg::queue=queue, arg::durable=true, arg::arguments=qo);
</programlisting>
	  <!--h4--></section>
          <section role="h4" id="CheatSheetforconfiguringQueueOptions-Queueeventgeneration"><title>
            Queue
            event generation
          </title>
          <para>
            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
            <xref linkend="queue-state-replication"/>.
          </para><para>
            Example:
          </para>
            <programlisting>
#include "qpid/client/QueueOptions.h"

    QueueOptions options;
    options.enableQueueEvents(1);
    session.queueDeclare(arg::queue="my-queue", arg::arguments=options);
</programlisting>
          <para>
            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).
          </para>
	  <!--h3--></section>
	  <!--h4--></section>
	  <section role="h3" id="CheatSheetforconfiguringQueueOptions-OtherClients"><title>
            Other
            Clients
          </title>
          <para>
            Note that these options can be set from any client. QueueOptions
            just correctly formats the arguments passed to the QueueDeclare()
            method.
          </para>

	  <!--h3--></section>
	  
	<!--h2--></section>


</section>