summaryrefslogtreecommitdiff
path: root/reference/kombu.messaging.html
blob: efd54360d59ae8e3a0b738517ecce112cfb90d97 (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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>kombu.messaging &mdash; Kombu v1.0.1 documentation</title>
    <link rel="stylesheet" href="../static/celery.css" type="text/css" />
    <link rel="stylesheet" href="../static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.0.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../static/jquery.js"></script>
    <script type="text/javascript" src="../static/underscore.js"></script>
    <script type="text/javascript" src="../static/doctools.js"></script>
    <link rel="top" title="Kombu v1.0.1 documentation" href="../index.html" />
    <link rel="up" title="API Reference" href="index.html" />
    <link rel="next" title="kombu.entity" href="kombu.entity.html" />
    <link rel="prev" title="kombu.simple" href="kombu.simple.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="kombu.entity.html" title="kombu.entity"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="kombu.simple.html" title="kombu.simple"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">Kombu v1.0.1 documentation</a> &raquo;</li>
          <li><a href="index.html" accesskey="U">API Reference</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <span class="target" id="module-kombu.messaging"></span><div class="section" id="kombu-messaging">
<h1>kombu.messaging<a class="headerlink" href="#kombu-messaging" title="Permalink to this headline">¶</a></h1>
<p>Sending and receiving messages.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">copyright:</th><td class="field-body"><ol class="first loweralpha simple" start="3">
<li>2009 - 2010 by Ask Solem.</li>
</ol>
</td>
</tr>
<tr class="field"><th class="field-name">license:</th><td class="field-body"><p class="first last">BSD, see LICENSE for more details.</p>
</td>
</tr>
</tbody>
</table>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#message-producer" id="id1">Message Producer</a></li>
<li><a class="reference internal" href="#message-consumer" id="id2">Message Consumer</a></li>
</ul>
</div>
<div class="section" id="message-producer">
<h2><a class="toc-backref" href="#id1">Message Producer</a><a class="headerlink" href="#message-producer" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="kombu.messaging.Producer">
<em class="property">class </em><tt class="descclassname">kombu.messaging.</tt><tt class="descname">Producer</tt><big>(</big><em>channel</em>, <em>exchange=None</em>, <em>routing_key=None</em>, <em>serializer=None</em>, <em>auto_declare=None</em>, <em>compression=None</em>, <em>on_return=None</em><big>)</big><a class="headerlink" href="#kombu.messaging.Producer" title="Permalink to this definition">¶</a></dt>
<dd><p>Message Producer.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>channel</strong> &#8211; Connection channel.</li>
<li><strong>exchange</strong> &#8211; Default exchange.</li>
<li><strong>routing_key</strong> &#8211; Default routing key.</li>
<li><strong>serializer</strong> &#8211; Default serializer. Default is <cite>&#8220;json&#8221;</cite>.</li>
<li><strong>compression</strong> &#8211; Default compression method. Default is no
compression.</li>
<li><strong>auto_declare</strong> &#8211; Automatically declare the exchange
at instantiation. Default is <tt class="xref py py-const xref docutils literal"><span class="pre">True</span></tt>.</li>
<li><strong>on_return</strong> &#8211; Callback to call for undeliverable messages,
when the <cite>mandatory</cite> or <cite>imediate</cite> arguments to
<a class="reference internal" href="#kombu.messaging.Producer.publish" title="kombu.messaging.Producer.publish"><tt class="xref py py-meth docutils literal"><span class="pre">publish()</span></tt></a> is used. This callback needs the following
signature: <cite>(exception, exchange, routing_key, message)</cite>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="kombu.messaging.Producer.channel">
<tt class="descname">channel</tt><a class="headerlink" href="#kombu.messaging.Producer.channel" title="Permalink to this definition">¶</a></dt>
<dd><p>The connection channel used.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Producer.exchange">
<tt class="descname">exchange</tt><a class="headerlink" href="#kombu.messaging.Producer.exchange" title="Permalink to this definition">¶</a></dt>
<dd><p>An Exchange declaration.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>name</strong> &#8211; See <a class="reference internal" href="#kombu.messaging.Producer.name" title="kombu.messaging.Producer.name"><tt class="xref py py-attr docutils literal"><span class="pre">name</span></tt></a>.</li>
<li><strong>type</strong> &#8211; See <a class="reference internal" href="#kombu.messaging.Producer.type" title="kombu.messaging.Producer.type"><tt class="xref py py-attr docutils literal"><span class="pre">type</span></tt></a>.</li>
<li><strong>channel</strong> &#8211; See <a class="reference internal" href="#kombu.messaging.Producer.channel" title="kombu.messaging.Producer.channel"><tt class="xref py py-attr docutils literal"><span class="pre">channel</span></tt></a>.</li>
<li><strong>durable</strong> &#8211; See <a class="reference internal" href="#kombu.messaging.Producer.durable" title="kombu.messaging.Producer.durable"><tt class="xref py py-attr docutils literal"><span class="pre">durable</span></tt></a>.</li>
<li><strong>auto_delete</strong> &#8211; See <a class="reference internal" href="#kombu.messaging.Producer.auto_delete" title="kombu.messaging.Producer.auto_delete"><tt class="xref py py-attr docutils literal"><span class="pre">auto_delete</span></tt></a>.</li>
<li><strong>delivery_mode</strong> &#8211; See <a class="reference internal" href="#kombu.messaging.Producer.delivery_mode" title="kombu.messaging.Producer.delivery_mode"><tt class="xref py py-attr docutils literal"><span class="pre">delivery_mode</span></tt></a>.</li>
<li><strong>arguments</strong> &#8211; See <a class="reference internal" href="#kombu.messaging.Producer.arguments" title="kombu.messaging.Producer.arguments"><tt class="xref py py-attr docutils literal"><span class="pre">arguments</span></tt></a>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="kombu.messaging.Producer.name">
<tt class="descname">name</tt><a class="headerlink" href="#kombu.messaging.Producer.name" title="Permalink to this definition">¶</a></dt>
<dd><p>Name of the exchange. Default is no name (the default exchange).</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Producer.type">
<tt class="descname">type</tt><a class="headerlink" href="#kombu.messaging.Producer.type" title="Permalink to this definition">¶</a></dt>
<dd><p>AMQP defines four default exchange types (routing algorithms) that
covers most of the common messaging use cases. An AMQP broker can
also define additional exchange types, so see your broker
manual for more information about available exchange types.</p>
<blockquote>
<ul>
<li><p class="first"><cite>direct</cite> (<em>default</em>)</p>
<blockquote>
<p>Direct match between the routing key in the message, and the
routing criteria used when a queue is bound to this exchange.</p>
</blockquote>
</li>
<li><p class="first"><cite>topic</cite></p>
<blockquote>
<p>Wildcard match between the routing key and the routing pattern
specified in the exchange/queue binding. The routing key is
treated as zero or more words delimited by <cite>&#8221;.&#8221;</cite> and
supports special wildcard characters. <cite>&#8220;*&#8221;</cite> matches a
single word and <cite>&#8220;#&#8221;</cite> matches zero or more words.</p>
</blockquote>
</li>
<li><p class="first"><cite>fanout</cite></p>
<blockquote>
<p>Queues are bound to this exchange with no arguments. Hence any
message sent to this exchange will be forwarded to all queues
bound to this exchange.</p>
</blockquote>
</li>
<li><p class="first"><cite>headers</cite></p>
<blockquote>
<p>Queues are bound to this exchange with a table of arguments
containing headers and values (optional). A special argument
named &#8220;x-match&#8221; determines the matching algorithm, where
<cite>&#8220;all&#8221;</cite> implies an <cite>AND</cite> (all pairs must match) and
<cite>&#8220;any&#8221;</cite> implies <cite>OR</cite> (at least one pair must match).</p>
<p><a class="reference internal" href="#kombu.messaging.Producer.arguments" title="kombu.messaging.Producer.arguments"><tt class="xref py py-attr docutils literal"><span class="pre">arguments</span></tt></a> is used to specify the arguments.</p>
</blockquote>
</li>
</ul>
<p>This description of AMQP exchange types was shamelessly stolen
from the blog post <a class="reference external" href="http://bit.ly/amqp-exchange-types">AMQP in 10 minutes: Part 4</a> by
Rajith Attapattu. This article is recommended reading.</p>
</blockquote>
</dd></dl>

<dl class="attribute">
<dt>
<tt class="descname">channel</tt></dt>
<dd><p>The channel the exchange is bound to (if bound).</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Producer.durable">
<tt class="descname">durable</tt><a class="headerlink" href="#kombu.messaging.Producer.durable" title="Permalink to this definition">¶</a></dt>
<dd><p>Durable exchanges remain active when a server restarts. Non-durable
exchanges (transient exchanges) are purged when a server restarts.
Default is <tt class="xref py py-const xref docutils literal"><span class="pre">True</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Producer.auto_delete">
<tt class="descname">auto_delete</tt><a class="headerlink" href="#kombu.messaging.Producer.auto_delete" title="Permalink to this definition">¶</a></dt>
<dd><p>If set, the exchange is deleted when all queues have finished
using it. Default is <tt class="xref py py-const xref docutils literal"><span class="pre">False</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Producer.delivery_mode">
<tt class="descname">delivery_mode</tt><a class="headerlink" href="#kombu.messaging.Producer.delivery_mode" title="Permalink to this definition">¶</a></dt>
<dd><p>The default delivery mode used for messages. The value is an integer,
or alias string.</p>
<blockquote>
<ul>
<li><p class="first">1 or <cite>&#8220;transient&#8221;</cite></p>
<blockquote>
<p>The message is transient. Which means it is stored in
memory only, and is lost if the server dies or restarts.</p>
</blockquote>
</li>
<li><dl class="first docutils">
<dt>2 or &#8220;persistent&#8221; (<em>default</em>)</dt>
<dd><p class="first last">The message is persistent. Which means the message is
stored both in-memory, and on disk, and therefore
preserved if the server dies or restarts.</p>
</dd>
</dl>
</li>
</ul>
</blockquote>
<p>The default value is 2 (persistent).</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Producer.arguments">
<tt class="descname">arguments</tt><a class="headerlink" href="#kombu.messaging.Producer.arguments" title="Permalink to this definition">¶</a></dt>
<dd><p>Additional arguments to specify when the exchange is declared.</p>
</dd></dl>

</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Producer.routing_key">
<tt class="descname">routing_key</tt><a class="headerlink" href="#kombu.messaging.Producer.routing_key" title="Permalink to this definition">¶</a></dt>
<dd><p>str(object) -&gt; string</p>
<p>Return a nice string representation of the object.
If the argument is a string, the return value is the same object.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Producer.serializer">
<tt class="descname">serializer</tt><a class="headerlink" href="#kombu.messaging.Producer.serializer" title="Permalink to this definition">¶</a></dt>
<dd><p>Default serializer to use. Default is JSON.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Producer.compression">
<tt class="descname">compression</tt><a class="headerlink" href="#kombu.messaging.Producer.compression" title="Permalink to this definition">¶</a></dt>
<dd><p>Default compression method.  Disabled by default.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Producer.auto_declare">
<tt class="descname">auto_declare</tt><a class="headerlink" href="#kombu.messaging.Producer.auto_declare" title="Permalink to this definition">¶</a></dt>
<dd><p>By default the exchange is declared at instantiation.
If you want to declare manually then you can set this
to <tt class="xref py py-const xref docutils literal"><span class="pre">False</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Producer.on_return">
<tt class="descname">on_return</tt><a class="headerlink" href="#kombu.messaging.Producer.on_return" title="Permalink to this definition">¶</a></dt>
<dd><p>Basic return callback.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Producer.declare">
<tt class="descname">declare</tt><big>(</big><big>)</big><a class="headerlink" href="#kombu.messaging.Producer.declare" title="Permalink to this definition">¶</a></dt>
<dd><p>Declare the exchange.</p>
<p>This is done automatically at instantiation if <a class="reference internal" href="#kombu.messaging.Producer.auto_declare" title="kombu.messaging.Producer.auto_declare"><tt class="xref py py-attr docutils literal"><span class="pre">auto_declare</span></tt></a>
is set to <tt class="xref py py-const xref docutils literal"><span class="pre">True</span></tt>.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Producer.publish">
<tt class="descname">publish</tt><big>(</big><em>body</em>, <em>routing_key=None</em>, <em>delivery_mode=None</em>, <em>mandatory=False</em>, <em>immediate=False</em>, <em>priority=0</em>, <em>content_type=None</em>, <em>content_encoding=None</em>, <em>serializer=None</em>, <em>headers=None</em>, <em>compression=None</em>, <em>exchange=None</em><big>)</big><a class="headerlink" href="#kombu.messaging.Producer.publish" title="Permalink to this definition">¶</a></dt>
<dd><p>Publish message to the specified exchange.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>body</strong> &#8211; Message body.</li>
<li><strong>routing_key</strong> &#8211; Message routing key.</li>
<li><strong>delivery_mode</strong> &#8211; See <a class="reference internal" href="#kombu.messaging.Producer.delivery_mode" title="kombu.messaging.Producer.delivery_mode"><tt class="xref py py-attr docutils literal"><span class="pre">delivery_mode</span></tt></a>.</li>
<li><strong>mandatory</strong> &#8211; Currently not supported.</li>
<li><strong>immediate</strong> &#8211; Currently not supported.</li>
<li><strong>priority</strong> &#8211; Message priority. A number between 0 and 9.</li>
<li><strong>content_type</strong> &#8211; Content type. Default is autodetect.</li>
<li><strong>content_encoding</strong> &#8211; Content encoding. Default is autodetect.</li>
<li><strong>serializer</strong> &#8211; Serializer to use. Default is autodetect.</li>
<li><strong>headers</strong> &#8211; Mapping of arbitrary headers to pass along
with the message body.</li>
<li><strong>exchange</strong> &#8211; Override the exchange.  Note that this exchange
must have been declared.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Producer.revive">
<tt class="descname">revive</tt><big>(</big><em>channel</em><big>)</big><a class="headerlink" href="#kombu.messaging.Producer.revive" title="Permalink to this definition">¶</a></dt>
<dd><p>Revive the producer after connection loss.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="message-consumer">
<h2><a class="toc-backref" href="#id2">Message Consumer</a><a class="headerlink" href="#message-consumer" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="kombu.messaging.Consumer">
<em class="property">class </em><tt class="descclassname">kombu.messaging.</tt><tt class="descname">Consumer</tt><big>(</big><em>channel</em>, <em>queues</em>, <em>no_ack=None</em>, <em>auto_declare=None</em>, <em>callbacks=None</em>, <em>on_decode_error=None</em><big>)</big><a class="headerlink" href="#kombu.messaging.Consumer" title="Permalink to this definition">¶</a></dt>
<dd><p>Message consumer.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>channel</strong> &#8211; see <a class="reference internal" href="#kombu.messaging.Consumer.channel" title="kombu.messaging.Consumer.channel"><tt class="xref py py-attr docutils literal"><span class="pre">channel</span></tt></a>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p>:param queues see <a class="reference internal" href="#kombu.messaging.Consumer.queues" title="kombu.messaging.Consumer.queues"><tt class="xref py py-attr docutils literal"><span class="pre">queues</span></tt></a>.
:keyword no_ack: see <a class="reference internal" href="#kombu.messaging.Consumer.no_ack" title="kombu.messaging.Consumer.no_ack"><tt class="xref py py-attr docutils literal"><span class="pre">no_ack</span></tt></a>.
:keyword auto_declare: see <a class="reference internal" href="#kombu.messaging.Consumer.auto_declare" title="kombu.messaging.Consumer.auto_declare"><tt class="xref py py-attr docutils literal"><span class="pre">auto_declare</span></tt></a>
:keyword callbacks: see <a class="reference internal" href="#kombu.messaging.Consumer.callbacks" title="kombu.messaging.Consumer.callbacks"><tt class="xref py py-attr docutils literal"><span class="pre">callbacks</span></tt></a>.
:keyword on_decode_error: see <a class="reference internal" href="#kombu.messaging.Consumer.on_decode_error" title="kombu.messaging.Consumer.on_decode_error"><tt class="xref py py-attr docutils literal"><span class="pre">on_decode_error</span></tt></a>.</p>
<dl class="attribute">
<dt id="kombu.messaging.Consumer.channel">
<tt class="descname">channel</tt><a class="headerlink" href="#kombu.messaging.Consumer.channel" title="Permalink to this definition">¶</a></dt>
<dd><p>The connection channel to use.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Consumer.queues">
<tt class="descname">queues</tt><a class="headerlink" href="#kombu.messaging.Consumer.queues" title="Permalink to this definition">¶</a></dt>
<dd><p>A single <a class="reference internal" href="kombu.entity.html#kombu.entity.Queue" title="kombu.entity.Queue"><tt class="xref py py-class docutils literal"><span class="pre">Queue</span></tt></a>, or a list of queues to
consume from.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Consumer.no_ack">
<tt class="descname">no_ack</tt><a class="headerlink" href="#kombu.messaging.Consumer.no_ack" title="Permalink to this definition">¶</a></dt>
<dd><p>Flag for message acknowledgment disabled/enabled.
Enabled by default.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Consumer.auto_declare">
<tt class="descname">auto_declare</tt><a class="headerlink" href="#kombu.messaging.Consumer.auto_declare" title="Permalink to this definition">¶</a></dt>
<dd><p>By default all entities will be declared at instantiation, if you
want to handle this manually you can set this to <tt class="xref py py-const xref docutils literal"><span class="pre">False</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Consumer.callbacks">
<tt class="descname">callbacks</tt><a class="headerlink" href="#kombu.messaging.Consumer.callbacks" title="Permalink to this definition">¶</a></dt>
<dd><p>List of callbacks called in order when a message is received.</p>
<p>The signature of the callbacks must take two arguments:
<cite>(body, message)</cite>, which is the decoded message body and
the <cite>Message</cite> instance (a subclass of
<a class="reference internal" href="kombu.transport.base.html#kombu.transport.base.Message" title="kombu.transport.base.Message"><tt class="xref py py-class docutils literal"><span class="pre">Message</span></tt></a>).</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.messaging.Consumer.on_decode_error">
<tt class="descname">on_decode_error</tt><a class="headerlink" href="#kombu.messaging.Consumer.on_decode_error" title="Permalink to this definition">¶</a></dt>
<dd><p>Callback called when a message can&#8217;t be decoded.</p>
<p>The signature of the callback must take two arguments: <cite>(message,
exc)</cite>, which is the message that can&#8217;t be decoded and the exception
that occured while trying to decode it.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Consumer.declare">
<tt class="descname">declare</tt><big>(</big><big>)</big><a class="headerlink" href="#kombu.messaging.Consumer.declare" title="Permalink to this definition">¶</a></dt>
<dd><p>Declare queues, exchanges and bindings.</p>
<p>This is done automatically at instantiation if <a class="reference internal" href="#kombu.messaging.Consumer.auto_declare" title="kombu.messaging.Consumer.auto_declare"><tt class="xref py py-attr docutils literal"><span class="pre">auto_declare</span></tt></a>
is set.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Consumer.register_callback">
<tt class="descname">register_callback</tt><big>(</big><em>callback</em><big>)</big><a class="headerlink" href="#kombu.messaging.Consumer.register_callback" title="Permalink to this definition">¶</a></dt>
<dd><p>Register a new callback to be called when a message
is received.</p>
<p>The signature of the callback needs to accept two arguments:
<cite>(body, message)</cite>, which is the decoded message body
and the <cite>Message</cite> instance (a subclass of
<a class="reference internal" href="kombu.transport.base.html#kombu.transport.base.Message" title="kombu.transport.base.Message"><tt class="xref py py-class docutils literal"><span class="pre">Message</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Consumer.consume">
<tt class="descname">consume</tt><big>(</big><em>no_ack=None</em><big>)</big><a class="headerlink" href="#kombu.messaging.Consumer.consume" title="Permalink to this definition">¶</a></dt>
<dd><p>Register consumer on server.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Consumer.cancel">
<tt class="descname">cancel</tt><big>(</big><big>)</big><a class="headerlink" href="#kombu.messaging.Consumer.cancel" title="Permalink to this definition">¶</a></dt>
<dd><p>End all active queue consumers.</p>
<p>This does not affect already delivered messages, but it does
mean the server will not send any more messages for this consumer.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Consumer.cancel_by_queue">
<tt class="descname">cancel_by_queue</tt><big>(</big><em>queue</em><big>)</big><a class="headerlink" href="#kombu.messaging.Consumer.cancel_by_queue" title="Permalink to this definition">¶</a></dt>
<dd><p>Cancel consumer by queue name.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Consumer.purge">
<tt class="descname">purge</tt><big>(</big><big>)</big><a class="headerlink" href="#kombu.messaging.Consumer.purge" title="Permalink to this definition">¶</a></dt>
<dd><p>Purge messages from all queues.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This will <em>delete all ready messages</em>, there is no
undo operation available.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Consumer.flow">
<tt class="descname">flow</tt><big>(</big><em>active</em><big>)</big><a class="headerlink" href="#kombu.messaging.Consumer.flow" title="Permalink to this definition">¶</a></dt>
<dd><p>Enable/disable flow from peer.</p>
<p>This is a simple flow-control mechanism that a peer can use
to avoid overflowing its queues or otherwise finding itself
receiving more messages than it can process.</p>
<p>The peer that receives a request to stop sending content
will finish sending the current content (if any), and then wait
until flow is reactivated.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Consumer.qos">
<tt class="descname">qos</tt><big>(</big><em>prefetch_size=0</em>, <em>prefetch_count=0</em>, <em>apply_global=False</em><big>)</big><a class="headerlink" href="#kombu.messaging.Consumer.qos" title="Permalink to this definition">¶</a></dt>
<dd><p>Specify quality of service.</p>
<p>The client can request that messages should be sent in
advance so that when the client finishes processing a message,
the following message is already held locally, rather than needing
to be sent down the channel. Prefetching gives a performance
improvement.</p>
<p>The prefetch window is Ignored if the <a class="reference internal" href="#kombu.messaging.Consumer.no_ack" title="kombu.messaging.Consumer.no_ack"><tt class="xref py py-attr docutils literal"><span class="pre">no_ack</span></tt></a> option is set.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>prefetch_size</strong> &#8211; Specify the prefetch window in octets.
The server will send a message in advance if it is equal to
or smaller in size than the available prefetch size (and
also falls within other prefetch limits). May be set to zero,
meaning &#8220;no specific limit&#8221;, although other prefetch limits
may still apply.</li>
<li><strong>prefetch_count</strong> &#8211; Specify the prefetch window in terms of
whole messages.</li>
<li><strong>apply_global</strong> &#8211; Apply new settings globally on all channels.
Currently not supported by RabbitMQ.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Consumer.recover">
<tt class="descname">recover</tt><big>(</big><em>requeue=False</em><big>)</big><a class="headerlink" href="#kombu.messaging.Consumer.recover" title="Permalink to this definition">¶</a></dt>
<dd><p>Redeliver unacknowledged messages.</p>
<p>Asks the broker to redeliver all unacknowledged messages
on the specified channel.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>requeue</strong> &#8211; By default the messages will be redelivered
to the original recipient. With <cite>requeue</cite> set to true, the
server will attempt to requeue the message, potentially then
delivering it to an alternative subscriber.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Consumer.receive">
<tt class="descname">receive</tt><big>(</big><em>body</em>, <em>message</em><big>)</big><a class="headerlink" href="#kombu.messaging.Consumer.receive" title="Permalink to this definition">¶</a></dt>
<dd><p>Method called when a message is received.</p>
<p>This dispatches to the registered <a class="reference internal" href="#kombu.messaging.Consumer.callbacks" title="kombu.messaging.Consumer.callbacks"><tt class="xref py py-attr docutils literal"><span class="pre">callbacks</span></tt></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>body</strong> &#8211; The decoded message body.</li>
<li><strong>message</strong> &#8211; The <cite>Message</cite> instance.</li>
</ul>
</td>
</tr>
<tr class="field"><th class="field-name" colspan="2">Raises NotImplementedError:</th></tr>
<tr><td>&nbsp;</td><td class="field-body"><p class="first last">If no consumer callbacks have been
registered.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="kombu.messaging.Consumer.revive">
<tt class="descname">revive</tt><big>(</big><em>channel</em><big>)</big><a class="headerlink" href="#kombu.messaging.Consumer.revive" title="Permalink to this definition">¶</a></dt>
<dd><p>Revive consumer after connection loss.</p>
</dd></dl>

</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper"><p class="logo"><a href="../index.html">
  <img class="logo" width="128" height="128" src="http://cloud.github.com/downloads/ask/kombu/kombusmall.jpg" alt="Logo"/>
</a></p>
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">kombu.messaging</a><ul>
<li><a class="reference internal" href="#message-producer">Message Producer</a></li>
<li><a class="reference internal" href="#message-consumer">Message Consumer</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="kombu.simple.html"
                        title="previous chapter">kombu.simple</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="kombu.entity.html"
                        title="next chapter">kombu.entity</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../sources/reference/kombu.messaging.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="kombu.entity.html" title="kombu.entity"
             >next</a> |</li>
        <li class="right" >
          <a href="kombu.simple.html" title="kombu.simple"
             >previous</a> |</li>
        <li><a href="../index.html">Kombu v1.0.1 documentation</a> &raquo;</li>
          <li><a href="index.html" >API Reference</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009-2010, Ask Solem.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.4.
    </div>
  </body>
</html>