summaryrefslogtreecommitdiff
path: root/reference/kombu.entity.html
blob: a7472ea651488d602bf78018494034bcae1d0d54 (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
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773

<!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.entity &mdash; Kombu 2.1.3 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:     '2.1.3',
        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 2.1.3 documentation" href="../index.html" />
    <link rel="up" title="API Reference" href="index.html" />
    <link rel="next" title="Common Utilities - kombu.common" href="kombu.common.html" />
    <link rel="prev" title="kombu.messaging" href="kombu.messaging.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.common.html" title="Common Utilities - kombu.common"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="kombu.messaging.html" title="kombu.messaging"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">Kombu 2.1.3 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.entity"></span><div class="section" id="kombu-entity">
<h1>kombu.entity<a class="headerlink" href="#kombu-entity" title="Permalink to this headline">¶</a></h1>
<p>Exchange and Queue declarations.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">copyright:</th><td class="field-body"><ol class="first loweralpha simple" start="3">
<li>2009 - 2012 by Ask Solem.</li>
</ol>
</td>
</tr>
<tr class="field-even 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="#exchange" id="id1">Exchange</a></li>
<li><a class="reference internal" href="#queue" id="id2">Queue</a></li>
</ul>
</div>
<div class="section" id="exchange">
<h2><a class="toc-backref" href="#id1">Exchange</a><a class="headerlink" href="#exchange" title="Permalink to this headline">¶</a></h2>
<p>Example creating an exchange declaration:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">news_exchange</span> <span class="o">=</span> <span class="n">Exchange</span><span class="p">(</span><span class="s">&quot;news&quot;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="s">&quot;topic&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>For now <cite>news_exchange</cite> is just a declaration, you can&#8217;t perform
actions on it. It just describes the name and options for the exchange.</p>
<p>The exchange can be bound or unbound. Bound means the exchange is
associated with a channel and operations can be performed on it.
To bind the exchange you call the exchange with the channel as argument:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">bound_exchange</span> <span class="o">=</span> <span class="n">news_exchange</span><span class="p">(</span><span class="n">channel</span><span class="p">)</span>
</pre></div>
</div>
<p>Now you can perform operations like <tt class="xref py py-meth docutils literal"><span class="pre">declare()</span></tt> or <tt class="xref py py-meth docutils literal"><span class="pre">delete()</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">bound_exchange</span><span class="o">.</span><span class="n">declare</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">message</span> <span class="o">=</span> <span class="n">bound_exchange</span><span class="o">.</span><span class="n">Message</span><span class="p">(</span><span class="s">&quot;Cure for cancer found!&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">bound_exchange</span><span class="o">.</span><span class="n">publish</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="n">routing_key</span><span class="o">=</span><span class="s">&quot;news.science&quot;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">bound_exchange</span><span class="o">.</span><span class="n">delete</span><span class="p">()</span>
</pre></div>
</div>
<dl class="class">
<dt id="kombu.entity.Exchange">
<em class="property">class </em><tt class="descclassname">kombu.entity.</tt><tt class="descname">Exchange</tt><big>(</big><em>name=''</em>, <em>type=''</em>, <em>channel=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#kombu.entity.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-odd 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.entity.Exchange.name" title="kombu.entity.Exchange.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.entity.Exchange.type" title="kombu.entity.Exchange.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.entity.Exchange.channel" title="kombu.entity.Exchange.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.entity.Exchange.durable" title="kombu.entity.Exchange.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.entity.Exchange.auto_delete" title="kombu.entity.Exchange.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.entity.Exchange.delivery_mode" title="kombu.entity.Exchange.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.entity.Exchange.arguments" title="kombu.entity.Exchange.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.entity.Exchange.name">
<tt class="descname">name</tt><a class="headerlink" href="#kombu.entity.Exchange.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.entity.Exchange.type">
<tt class="descname">type</tt><a class="headerlink" href="#kombu.entity.Exchange.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>
<div><ul>
<li><p class="first"><cite>direct</cite> (<em>default</em>)</p>
<blockquote>
<div><p>Direct match between the routing key in the message, and the
routing criteria used when a queue is bound to this exchange.</p>
</div></blockquote>
</li>
<li><p class="first"><cite>topic</cite></p>
<blockquote>
<div><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>
</div></blockquote>
</li>
<li><p class="first"><cite>fanout</cite></p>
<blockquote>
<div><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>
</div></blockquote>
</li>
<li><p class="first"><cite>headers</cite></p>
<blockquote>
<div><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.entity.Exchange.arguments" title="kombu.entity.Exchange.arguments"><tt class="xref py py-attr docutils literal"><span class="pre">arguments</span></tt></a> is used to specify the arguments.</p>
</div></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>
</div></blockquote>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Exchange.channel">
<tt class="descname">channel</tt><a class="headerlink" href="#kombu.entity.Exchange.channel" title="Permalink to this definition">¶</a></dt>
<dd><p>The channel the exchange is bound to (if bound).</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Exchange.durable">
<tt class="descname">durable</tt><a class="headerlink" href="#kombu.entity.Exchange.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 docutils literal"><span class="pre">True</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Exchange.auto_delete">
<tt class="descname">auto_delete</tt><a class="headerlink" href="#kombu.entity.Exchange.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 docutils literal"><span class="pre">False</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Exchange.delivery_mode">
<tt class="descname">delivery_mode</tt><a class="headerlink" href="#kombu.entity.Exchange.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>
<div><ul>
<li><p class="first">1 or <cite>&#8220;transient&#8221;</cite></p>
<blockquote>
<div><p>The message is transient. Which means it is stored in
memory only, and is lost if the server dies or restarts.</p>
</div></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>
</div></blockquote>
<p>The default value is 2 (persistent).</p>
</dd></dl>

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

<dl class="method">
<dt id="kombu.entity.Exchange.maybe_bind">
<tt class="descname">maybe_bind</tt><big>(</big><em>channel</em><big>)</big><a class="headerlink" href="#kombu.entity.Exchange.maybe_bind" title="Permalink to this definition">¶</a></dt>
<dd><p>Bind instance to channel if not already bound.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.entity.Exchange.Message">
<tt class="descname">Message</tt><big>(</big><em>body</em>, <em>delivery_mode=None</em>, <em>priority=None</em>, <em>content_type=None</em>, <em>content_encoding=None</em>, <em>properties=None</em>, <em>headers=None</em><big>)</big><a class="headerlink" href="#kombu.entity.Exchange.Message" title="Permalink to this definition">¶</a></dt>
<dd><p>Create message instance to be sent with <a class="reference internal" href="#kombu.entity.Exchange.publish" title="kombu.entity.Exchange.publish"><tt class="xref py py-meth docutils literal"><span class="pre">publish()</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-odd 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>delivery_mode</strong> &#8211; Set custom delivery mode. Defaults
to <a class="reference internal" href="#kombu.entity.Exchange.delivery_mode" title="kombu.entity.Exchange.delivery_mode"><tt class="xref py py-attr docutils literal"><span class="pre">delivery_mode</span></tt></a>.</li>
<li><strong>priority</strong> &#8211; Message priority, 0 to 9. (currently not
supported by RabbitMQ).</li>
<li><strong>content_type</strong> &#8211; The messages content_type. If content_type
is set, no serialization occurs as it is assumed this is either
a binary object, or you&#8217;ve done your own serialization.
Leave blank if using built-in serialization as our library
properly sets content_type.</li>
<li><strong>content_encoding</strong> &#8211; The character set in which this object
is encoded. Use &#8220;binary&#8221; if sending in raw binary objects.
Leave blank if using built-in serialization as our library
properly sets content_encoding.</li>
<li><strong>properties</strong> &#8211; Message properties.</li>
<li><strong>headers</strong> &#8211; Message headers.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Exchange.PERSISTENT_DELIVERY_MODE">
<tt class="descname">PERSISTENT_DELIVERY_MODE</tt><em class="property"> = 2</em><a class="headerlink" href="#kombu.entity.Exchange.PERSISTENT_DELIVERY_MODE" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Exchange.TRANSIENT_DELIVERY_MODE">
<tt class="descname">TRANSIENT_DELIVERY_MODE</tt><em class="property"> = 1</em><a class="headerlink" href="#kombu.entity.Exchange.TRANSIENT_DELIVERY_MODE" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Exchange.attrs">
<tt class="descname">attrs</tt><em class="property"> = (('name', None), ('type', None), ('arguments', None), ('durable', &lt;type 'bool'&gt;), ('auto_delete', &lt;type 'bool'&gt;), ('delivery_mode', &lt;function &lt;lambda&gt; at 0x1026f8500&gt;))</em><a class="headerlink" href="#kombu.entity.Exchange.attrs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt>
<tt class="descname">auto_delete</tt><em class="property"> = False</em></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Exchange.can_cache_declaration">
<tt class="descname">can_cache_declaration</tt><a class="headerlink" href="#kombu.entity.Exchange.can_cache_declaration" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="kombu.entity.Exchange.declare">
<tt class="descname">declare</tt><big>(</big><em>nowait=False</em><big>)</big><a class="headerlink" href="#kombu.entity.Exchange.declare" title="Permalink to this definition">¶</a></dt>
<dd><p>Declare the exchange.</p>
<p>Creates the exchange on the broker.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>nowait</strong> &#8211; If set the server will not respond, and a
response will not be waited for. Default is <tt class="xref py py-const docutils literal"><span class="pre">False</span></tt>.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="kombu.entity.Exchange.delete">
<tt class="descname">delete</tt><big>(</big><em>if_unused=False</em>, <em>nowait=False</em><big>)</big><a class="headerlink" href="#kombu.entity.Exchange.delete" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete the exchange declaration on server.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>if_unused</strong> &#8211; Delete only if the exchange has no bindings.
Default is <tt class="xref py py-const docutils literal"><span class="pre">False</span></tt>.</li>
<li><strong>nowait</strong> &#8211; If set the server will not respond, and a
response will not be waited for. Default is <tt class="xref py py-const docutils literal"><span class="pre">False</span></tt>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt>
<tt class="descname">delivery_mode</tt><em class="property"> = 2</em></dt>
<dd></dd></dl>

<dl class="attribute">
<dt>
<tt class="descname">durable</tt><em class="property"> = True</em></dt>
<dd></dd></dl>

<dl class="attribute">
<dt>
<tt class="descname">name</tt><em class="property"> = ''</em></dt>
<dd></dd></dl>

<dl class="method">
<dt id="kombu.entity.Exchange.publish">
<tt class="descname">publish</tt><big>(</big><em>message</em>, <em>routing_key=None</em>, <em>mandatory=False</em>, <em>immediate=False</em>, <em>exchange=None</em><big>)</big><a class="headerlink" href="#kombu.entity.Exchange.publish" title="Permalink to this definition">¶</a></dt>
<dd><p>Publish message.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>message</strong> &#8211; <a class="reference internal" href="#kombu.entity.Exchange.Message" title="kombu.entity.Exchange.Message"><tt class="xref py py-meth docutils literal"><span class="pre">Message()</span></tt></a> instance to publish.</li>
<li><strong>routing_key</strong> &#8211; Routing key.</li>
<li><strong>mandatory</strong> &#8211; Currently not supported.</li>
<li><strong>immediate</strong> &#8211; Currently not supported.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt>
<tt class="descname">type</tt><em class="property"> = 'direct'</em></dt>
<dd></dd></dl>

</dd></dl>

</div>
<div class="section" id="queue">
<h2><a class="toc-backref" href="#id2">Queue</a><a class="headerlink" href="#queue" title="Permalink to this headline">¶</a></h2>
<p>Example creating a queue using our exchange in the <a class="reference internal" href="#kombu.entity.Exchange" title="kombu.entity.Exchange"><tt class="xref py py-class docutils literal"><span class="pre">Exchange</span></tt></a>
example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">science_news</span> <span class="o">=</span> <span class="n">Queue</span><span class="p">(</span><span class="s">&quot;science_news&quot;</span><span class="p">,</span>
<span class="gp">... </span>                     <span class="n">exchange</span><span class="o">=</span><span class="n">news_exchange</span><span class="p">,</span>
<span class="gp">... </span>                     <span class="n">routing_key</span><span class="o">=</span><span class="s">&quot;news.science&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>For now <cite>science_news</cite> is just a declaration, you can&#8217;t perform
actions on it. It just describes the name and options for the queue.</p>
<p>The queue can be bound or unbound. Bound means the queue is
associated with a channel and operations can be performed on it.
To bind the queue you call the queue instance with the channel as
an argument:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">bound_science_news</span> <span class="o">=</span> <span class="n">science_news</span><span class="p">(</span><span class="n">channel</span><span class="p">)</span>
</pre></div>
</div>
<p>Now you can perform operations like <tt class="xref py py-meth docutils literal"><span class="pre">declare()</span></tt> or <tt class="xref py py-meth docutils literal"><span class="pre">purge()</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">&gt;&gt;&gt; </span><span class="n">bound_sicence_news</span><span class="o">.</span><span class="n">declare</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">bound_science_news</span><span class="o">.</span><span class="n">purge</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">bound_science_news</span><span class="o">.</span><span class="n">delete</span><span class="p">()</span>
</pre></div>
</div>
<dl class="class">
<dt id="kombu.entity.Queue">
<em class="property">class </em><tt class="descclassname">kombu.entity.</tt><tt class="descname">Queue</tt><big>(</big><em>name=''</em>, <em>exchange=None</em>, <em>routing_key=''</em>, <em>channel=None</em>, <em>**kwargs</em><big>)</big><a class="headerlink" href="#kombu.entity.Queue" title="Permalink to this definition">¶</a></dt>
<dd><p>A Queue 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-odd 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.entity.Queue.name" title="kombu.entity.Queue.name"><tt class="xref py py-attr docutils literal"><span class="pre">name</span></tt></a>.</li>
<li><strong>exchange</strong> &#8211; See <a class="reference internal" href="#kombu.entity.Queue.exchange" title="kombu.entity.Queue.exchange"><tt class="xref py py-attr docutils literal"><span class="pre">exchange</span></tt></a>.</li>
<li><strong>routing_key</strong> &#8211; See <a class="reference internal" href="#kombu.entity.Queue.routing_key" title="kombu.entity.Queue.routing_key"><tt class="xref py py-attr docutils literal"><span class="pre">routing_key</span></tt></a>.</li>
<li><strong>channel</strong> &#8211; See <a class="reference internal" href="#kombu.entity.Queue.channel" title="kombu.entity.Queue.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.entity.Queue.durable" title="kombu.entity.Queue.durable"><tt class="xref py py-attr docutils literal"><span class="pre">durable</span></tt></a>.</li>
<li><strong>exclusive</strong> &#8211; See <a class="reference internal" href="#kombu.entity.Queue.exclusive" title="kombu.entity.Queue.exclusive"><tt class="xref py py-attr docutils literal"><span class="pre">exclusive</span></tt></a>.</li>
<li><strong>auto_delete</strong> &#8211; See <a class="reference internal" href="#kombu.entity.Queue.auto_delete" title="kombu.entity.Queue.auto_delete"><tt class="xref py py-attr docutils literal"><span class="pre">auto_delete</span></tt></a>.</li>
<li><strong>queue_arguments</strong> &#8211; See <a class="reference internal" href="#kombu.entity.Queue.queue_arguments" title="kombu.entity.Queue.queue_arguments"><tt class="xref py py-attr docutils literal"><span class="pre">queue_arguments</span></tt></a>.</li>
<li><strong>binding_arguments</strong> &#8211; See <a class="reference internal" href="#kombu.entity.Queue.binding_arguments" title="kombu.entity.Queue.binding_arguments"><tt class="xref py py-attr docutils literal"><span class="pre">binding_arguments</span></tt></a>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="kombu.entity.Queue.name">
<tt class="descname">name</tt><a class="headerlink" href="#kombu.entity.Queue.name" title="Permalink to this definition">¶</a></dt>
<dd><p>Name of the queue. Default is no name (default queue destination).</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Queue.exchange">
<tt class="descname">exchange</tt><a class="headerlink" href="#kombu.entity.Queue.exchange" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#kombu.entity.Exchange" title="kombu.entity.Exchange"><tt class="xref py py-class docutils literal"><span class="pre">Exchange</span></tt></a> the queue binds to.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Queue.routing_key">
<tt class="descname">routing_key</tt><a class="headerlink" href="#kombu.entity.Queue.routing_key" title="Permalink to this definition">¶</a></dt>
<dd><p>The routing key (if any), also called <em>binding key</em>.</p>
<p>The interpretation of the routing key depends on
the <a class="reference internal" href="#kombu.entity.Exchange.type" title="kombu.entity.Exchange.type"><tt class="xref py py-attr docutils literal"><span class="pre">Exchange.type</span></tt></a>.</p>
<blockquote>
<div><ul>
<li><p class="first">direct exchange</p>
<blockquote>
<div><p>Matches if the routing key property of the message and
the <a class="reference internal" href="#kombu.entity.Queue.routing_key" title="kombu.entity.Queue.routing_key"><tt class="xref py py-attr docutils literal"><span class="pre">routing_key</span></tt></a> attribute are identical.</p>
</div></blockquote>
</li>
<li><p class="first">fanout exchange</p>
<blockquote>
<div><p>Always matches, even if the binding does not have a key.</p>
</div></blockquote>
</li>
<li><p class="first">topic exchange</p>
<blockquote>
<div><p>Matches the routing key property of the message by a primitive
pattern matching scheme. The message routing key then consists
of words separated by dots (<cite>&#8221;.&#8221;</cite>, like domain names), and
two special characters are available; star (<cite>&#8220;*&#8221;</cite>) and hash
(<cite>&#8220;#&#8221;</cite>). The star matches any word, and the hash matches
zero or more words. For example <cite>&#8220;*.stock.#&#8221;</cite> matches the
routing keys <cite>&#8220;usd.stock&#8221;</cite> and <cite>&#8220;eur.stock.db&#8221;</cite> but not
<cite>&#8220;stock.nasdaq&#8221;</cite>.</p>
</div></blockquote>
</li>
</ul>
</div></blockquote>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Queue.channel">
<tt class="descname">channel</tt><a class="headerlink" href="#kombu.entity.Queue.channel" title="Permalink to this definition">¶</a></dt>
<dd><p>The channel the Queue is bound to (if bound).</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Queue.durable">
<tt class="descname">durable</tt><a class="headerlink" href="#kombu.entity.Queue.durable" title="Permalink to this definition">¶</a></dt>
<dd><p>Durable queues remain active when a server restarts.
Non-durable queues (transient queues) are purged if/when
a server restarts.
Note that durable queues do not necessarily hold persistent
messages, although it does not make sense to send
persistent messages to a transient queue.</p>
<p>Default is <tt class="xref py py-const docutils literal"><span class="pre">True</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Queue.exclusive">
<tt class="descname">exclusive</tt><a class="headerlink" href="#kombu.entity.Queue.exclusive" title="Permalink to this definition">¶</a></dt>
<dd><p>Exclusive queues may only be consumed from by the
current connection. Setting the &#8216;exclusive&#8217; flag
always implies &#8216;auto-delete&#8217;.</p>
<p>Default is <tt class="xref py py-const docutils literal"><span class="pre">False</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Queue.auto_delete">
<tt class="descname">auto_delete</tt><a class="headerlink" href="#kombu.entity.Queue.auto_delete" title="Permalink to this definition">¶</a></dt>
<dd><p>If set, the queue is deleted when all consumers have
finished using it. Last consumer can be cancelled
either explicitly or because its channel is closed. If
there was no consumer ever on the queue, it won&#8217;t be
deleted.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Queue.queue_arguments">
<tt class="descname">queue_arguments</tt><a class="headerlink" href="#kombu.entity.Queue.queue_arguments" title="Permalink to this definition">¶</a></dt>
<dd><p>Additional arguments used when declaring the queue.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Queue.binding_arguments">
<tt class="descname">binding_arguments</tt><a class="headerlink" href="#kombu.entity.Queue.binding_arguments" title="Permalink to this definition">¶</a></dt>
<dd><p>Additional arguments used when binding the queue.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Queue.alias">
<tt class="descname">alias</tt><a class="headerlink" href="#kombu.entity.Queue.alias" title="Permalink to this definition">¶</a></dt>
<dd><p>Unused in Kombu, but applications can take advantage of this.
For example to give alternate names to queues with automatically
generated queue names.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.entity.Queue.maybe_bind">
<tt class="descname">maybe_bind</tt><big>(</big><em>channel</em><big>)</big><a class="headerlink" href="#kombu.entity.Queue.maybe_bind" title="Permalink to this definition">¶</a></dt>
<dd><p>Bind instance to channel if not already bound.</p>
</dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Queue.attrs">
<tt class="descname">attrs</tt><em class="property"> = (('name', None), ('exchange', None), ('routing_key', None), ('queue_arguments', None), ('binding_arguments', None), ('durable', &lt;type 'bool'&gt;), ('exclusive', &lt;type 'bool'&gt;), ('auto_delete', &lt;type 'bool'&gt;), ('no_ack', None), ('alias', None))</em><a class="headerlink" href="#kombu.entity.Queue.attrs" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="attribute">
<dt>
<tt class="descname">auto_delete</tt><em class="property"> = False</em></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Queue.can_cache_declaration">
<tt class="descname">can_cache_declaration</tt><a class="headerlink" href="#kombu.entity.Queue.can_cache_declaration" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="kombu.entity.Queue.cancel">
<tt class="descname">cancel</tt><big>(</big><em>consumer_tag</em><big>)</big><a class="headerlink" href="#kombu.entity.Queue.cancel" title="Permalink to this definition">¶</a></dt>
<dd><p>Cancel a consumer by consumer tag.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.entity.Queue.consume">
<tt class="descname">consume</tt><big>(</big><em>consumer_tag=''</em>, <em>callback=None</em>, <em>no_ack=None</em>, <em>nowait=False</em><big>)</big><a class="headerlink" href="#kombu.entity.Queue.consume" title="Permalink to this definition">¶</a></dt>
<dd><p>Start a queue consumer.</p>
<p>Consumers last as long as the channel they were created on, or
until the client cancels them.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>consumer_tag</strong> &#8211; Unique identifier for the consumer. The
consumer tag is local to a connection, so two clients
can use the same consumer tags. If this field is empty
the server will generate a unique tag.</li>
<li><strong>no_ack</strong> &#8211; If set messages received does not have to
be acknowledged.</li>
<li><strong>nowait</strong> &#8211; Do not wait for a reply.</li>
<li><strong>callback</strong> &#8211; callback called for each delivered message</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="kombu.entity.Queue.declare">
<tt class="descname">declare</tt><big>(</big><em>nowait=False</em><big>)</big><a class="headerlink" href="#kombu.entity.Queue.declare" title="Permalink to this definition">¶</a></dt>
<dd><p>Declares the queue, the exchange and binds the queue to
the exchange.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.entity.Queue.delete">
<tt class="descname">delete</tt><big>(</big><em>if_unused=False</em>, <em>if_empty=False</em>, <em>nowait=False</em><big>)</big><a class="headerlink" href="#kombu.entity.Queue.delete" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete the queue.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>if_unused</strong> &#8211; If set, the server will only delete the queue
if it has no consumers. A channel error will be raised
if the queue has consumers.</li>
<li><strong>if_empty</strong> &#8211; If set, the server will only delete the queue
if it is empty. If it is not empty a channel error will be raised.</li>
<li><strong>nowait</strong> &#8211; Do not wait for a reply.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt>
<tt class="descname">durable</tt><em class="property"> = True</em></dt>
<dd></dd></dl>

<dl class="attribute">
<dt>
<tt class="descname">exchange</tt><em class="property"> = &lt;unbound Exchange (direct)&gt;</em></dt>
<dd></dd></dl>

<dl class="attribute">
<dt>
<tt class="descname">exclusive</tt><em class="property"> = False</em></dt>
<dd></dd></dl>

<dl class="method">
<dt id="kombu.entity.Queue.get">
<tt class="descname">get</tt><big>(</big><em>no_ack=None</em><big>)</big><a class="headerlink" href="#kombu.entity.Queue.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Poll the server for a new message.</p>
<p>Returns the message instance if a message was available,
or <tt class="xref py py-const docutils literal"><span class="pre">None</span></tt> otherwise.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>no_ack</strong> &#8211; If set messages received does not have to
be acknowledged.</td>
</tr>
</tbody>
</table>
<p>This method provides direct access to the messages in a
queue using a synchronous dialogue, designed for
specific types of applications where synchronous functionality
is more important than performance.</p>
</dd></dl>

<dl class="attribute">
<dt>
<tt class="descname">name</tt><em class="property"> = ''</em></dt>
<dd></dd></dl>

<dl class="attribute">
<dt id="kombu.entity.Queue.no_ack">
<tt class="descname">no_ack</tt><em class="property"> = False</em><a class="headerlink" href="#kombu.entity.Queue.no_ack" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="kombu.entity.Queue.purge">
<tt class="descname">purge</tt><big>(</big><em>nowait=False</em><big>)</big><a class="headerlink" href="#kombu.entity.Queue.purge" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove all ready messages from the queue.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.entity.Queue.queue_bind">
<tt class="descname">queue_bind</tt><big>(</big><em>nowait=False</em><big>)</big><a class="headerlink" href="#kombu.entity.Queue.queue_bind" title="Permalink to this definition">¶</a></dt>
<dd><p>Create the queue binding on the server.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.entity.Queue.queue_declare">
<tt class="descname">queue_declare</tt><big>(</big><em>nowait=False</em>, <em>passive=False</em><big>)</big><a class="headerlink" href="#kombu.entity.Queue.queue_declare" title="Permalink to this definition">¶</a></dt>
<dd><p>Declare queue on the server.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>nowait</strong> &#8211; Do not wait for a reply.</li>
<li><strong>passive</strong> &#8211; If set, the server will not create the queue.
The client can use this to check whether a queue exists
without modifying the server state.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="attribute">
<dt>
<tt class="descname">routing_key</tt><em class="property"> = ''</em></dt>
<dd></dd></dl>

<dl class="method">
<dt id="kombu.entity.Queue.unbind">
<tt class="descname">unbind</tt><big>(</big><big>)</big><a class="headerlink" href="#kombu.entity.Queue.unbind" title="Permalink to this definition">¶</a></dt>
<dd><p>Delete the binding on the server.</p>
</dd></dl>

<dl class="method">
<dt id="kombu.entity.Queue.when_bound">
<tt class="descname">when_bound</tt><big>(</big><big>)</big><a class="headerlink" href="#kombu.entity.Queue.when_bound" title="Permalink to this definition">¶</a></dt>
<dd></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.entity</a><ul>
<li><a class="reference internal" href="#exchange">Exchange</a></li>
<li><a class="reference internal" href="#queue">Queue</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="kombu.messaging.html"
                        title="previous chapter">kombu.messaging</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="kombu.common.html"
                        title="next chapter">Common Utilities - kombu.common</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/reference/kombu.entity.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" />
      <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.common.html" title="Common Utilities - kombu.common"
             >next</a> |</li>
        <li class="right" >
          <a href="kombu.messaging.html" title="kombu.messaging"
             >previous</a> |</li>
        <li><a href="../index.html">Kombu 2.1.3 documentation</a> &raquo;</li>
          <li><a href="index.html" >API Reference</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2009-2012, Ask Solem.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
    </div>
  </body>
</html>