summaryrefslogtreecommitdiff
path: root/userguide/producers.html
blob: 5528d18aac95ae6770e50833818590c20580c37a (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

<!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>Producers &mdash; Kombu 2.1.0 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.0',
        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.0 documentation" href="../index.html" />
    <link rel="up" title="User Guide" href="index.html" />
    <link rel="next" title="Consumers" href="consumers.html" />
    <link rel="prev" title="Connections and transports" href="connections.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="consumers.html" title="Consumers"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="connections.html" title="Connections and transports"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">Kombu 2.1.0 documentation</a> &raquo;</li>
          <li><a href="index.html" accesskey="U">User Guide</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="producers">
<span id="guide-producers"></span><h1>Producers<a class="headerlink" href="#producers" title="Permalink to this headline">¶</a></h1>
<div class="section" id="basics">
<span id="producer-basics"></span><h2>Basics<a class="headerlink" href="#basics" title="Permalink to this headline">¶</a></h2>
</div>
<div class="section" id="serialization">
<h2>Serialization<a class="headerlink" href="#serialization" title="Permalink to this headline">¶</a></h2>
<p>See <a class="reference internal" href="serialization.html#guide-serialization"><em>Serialization</em></a>.</p>
</div>
<div class="section" id="module-kombu.messaging">
<span id="reference"></span><h2>Reference<a class="headerlink" href="#module-kombu.messaging" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt>
<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></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-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>channel</strong> &#8211; Connection or channel.</li>
<li><strong>exchange</strong> &#8211; Optional default exchange.</li>
<li><strong>routing_key</strong> &#8211; Optional 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 default exchange
at instantiation. Default is <tt class="xref py py-const 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>immediate</cite> arguments to
<tt class="xref py py-meth docutils literal"><span class="pre">publish()</span></tt> is used. This callback needs the following
signature: <cite>(exception, exchange, routing_key, message)</cite>.
Note that the producer needs to drain events to use this feature.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt>
<tt class="descclassname">Producer.</tt><tt class="descname">auto_declare</tt><em class="property"> = True</em></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 docutils literal"><span class="pre">False</span></tt>.</p>
</dd></dl>

<dl class="attribute">
<dt>
<tt class="descclassname">Producer.</tt><tt class="descname">channel</tt><em class="property"> = None</em></dt>
<dd><p>The connection channel used.</p>
</dd></dl>

<dl class="attribute">
<dt>
<tt class="descclassname">Producer.</tt><tt class="descname">compression</tt><em class="property"> = None</em></dt>
<dd><p>Default compression method.  Disabled by default.</p>
</dd></dl>

<dl class="method">
<dt>
<tt class="descclassname">Producer.</tt><tt class="descname">declare</tt><big>(</big><big>)</big></dt>
<dd><p>Declare the exchange.</p>
<p>This happens automatically at instantiation if
<tt class="xref py py-attr docutils literal"><span class="pre">auto_declare</span></tt> is enabled.</p>
</dd></dl>

<dl class="attribute">
<dt>
<tt class="descclassname">Producer.</tt><tt class="descname">exchange</tt><em class="property"> = None</em></dt>
<dd><p>Default exchange.</p>
</dd></dl>

<dl class="method">
<dt>
<tt class="descclassname">Producer.</tt><tt class="descname">maybe_declare</tt><big>(</big><em>entity</em>, <em>retry=False</em>, <em>**retry_policy</em><big>)</big></dt>
<dd><p>Declare the exchange if it hasn&#8217;t already been declared
during this session.</p>
</dd></dl>

<dl class="attribute">
<dt>
<tt class="descclassname">Producer.</tt><tt class="descname">on_return</tt><em class="property"> = None</em></dt>
<dd><p>Basic return callback.</p>
</dd></dl>

<dl class="method">
<dt>
<tt class="descclassname">Producer.</tt><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>, <em>retry=False</em>, <em>retry_policy=None</em>, <em>declare=</em><span class="optional">[</span><span class="optional">]</span>, <em>**properties</em><big>)</big></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-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>routing_key</strong> &#8211; Message routing key.</li>
<li><strong>delivery_mode</strong> &#8211; See <tt class="xref py py-attr docutils literal"><span class="pre">delivery_mode</span></tt>.</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 auto-detect.</li>
<li><strong>content_encoding</strong> &#8211; Content encoding. Default is auto-detect.</li>
<li><strong>serializer</strong> &#8211; Serializer to use. Default is auto-detect.</li>
<li><strong>compression</strong> &#8211; Compression method to use.  Default is none.</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>
<li><strong>declare</strong> &#8211; Optional list of required entities that must
have been declared before publishing the message.  The entities
will be declared using <a class="reference internal" href="../reference/kombu.common.html#kombu.common.maybe_declare" title="kombu.common.maybe_declare"><tt class="xref py py-func docutils literal"><span class="pre">maybe_declare()</span></tt></a>.</li>
<li><strong>retry</strong> &#8211; Retry publishing, or declaring entities if the
connection is lost.</li>
<li><strong>retry_policy</strong> &#8211; Retry configuration, this is the keywords
supported by <tt class="xref py py-meth docutils literal"><span class="pre">ensure()</span></tt>.</li>
<li><strong>**properties</strong> &#8211; Additional message properties, see AMQP spec.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt>
<tt class="descclassname">Producer.</tt><tt class="descname">revive</tt><big>(</big><em>channel</em><big>)</big></dt>
<dd><p>Revive the producer after connection loss.</p>
</dd></dl>

<dl class="attribute">
<dt>
<tt class="descclassname">Producer.</tt><tt class="descname">serializer</tt><em class="property"> = None</em></dt>
<dd><p>Default serializer to use. Default is JSON.</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="#">Producers</a><ul>
<li><a class="reference internal" href="#basics">Basics</a></li>
<li><a class="reference internal" href="#serialization">Serialization</a></li>
<li><a class="reference internal" href="#module-kombu.messaging">Reference</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="connections.html"
                        title="previous chapter">Connections and transports</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="consumers.html"
                        title="next chapter">Consumers</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/userguide/producers.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="consumers.html" title="Consumers"
             >next</a> |</li>
        <li class="right" >
          <a href="connections.html" title="Connections and transports"
             >previous</a> |</li>
        <li><a href="../index.html">Kombu 2.1.0 documentation</a> &raquo;</li>
          <li><a href="index.html" >User Guide</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>