| <?xml version="1.0" encoding="utf-8"?> |
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" |
| "DTD/xhtml1-strict.dtd"> |
| <html> |
| |
| |
| <head> |
| |
| <title>pulsar.Producer</title> |
| <meta name="generator" content="pydoctor 25.4.0"> |
| |
| </meta> |
| <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> |
| <meta name="viewport" content="width=device-width, initial-scale=1 maximum-scale=1" /> |
| <link rel="stylesheet" type="text/css" href="apidocs.css" /> |
| <link rel="stylesheet" type="text/css" href="readthedocstheme.css" /> |
| <link rel="stylesheet" type="text/css" href="extra.css" /> |
| |
| </head> |
| |
| <body> |
| |
| |
| |
| <nav class="navbar navbar-default mainnavbar"> |
| |
| |
| <div class="container-fluid"> |
| |
| |
| <div class="navbar-header"> |
| |
| <div class="navlinks"> |
| <span class="navbar-brand"> |
| _pulsar/pulsar <a href="index.html">API Documentation</a> |
| </span> |
| |
| <a href="moduleIndex.html"> |
| Modules |
| </a> |
| |
| <a href="classIndex.html"> |
| Classes |
| </a> |
| |
| <a href="nameIndex.html"> |
| Names |
| </a> |
| |
| <div id="search-box-container"> |
| <div class="input-group"> |
| <input id="search-box" type="search" name="search-query" placeholder="Search..." aria-label="Search" minlength="2" class="form-control" autocomplete="off" /> |
| |
| <span class="input-group-btn"> |
| <a style="display: none;" class="btn btn-default" id="search-clear-button" title="Clear" onclick="clearSearch()"><img src="fonts/x-circle.svg" alt="Clear" /></a> |
| <a class="btn btn-default" id="apidocs-help-button" title="Help" href="apidocs-help.html"><img src="fonts/info.svg" alt="Help" /></a> |
| </span> |
| </div> |
| </div> |
| |
| </div> |
| |
| <div id="search-results-container" style="display: none;"> |
| |
| <div id="search-buttons"> |
| <span class="label label-default" id="search-docstrings-button"> |
| <label class="checkbox-inline"> |
| <input type="checkbox" id="toggle-search-in-docstrings-checkbox" value="false" onclick="toggleSearchInDocstrings()"> |
| search in docstrings |
| </input> |
| </label> |
| </span> |
| |
| </div> |
| |
| <noscript> |
| <h1>Cannot search: JavaScript is not supported/enabled in your browser.</h1> |
| </noscript> |
| |
| <div id="search-status"> </div> |
| |
| <div class="warning" id="search-warn-box" style="display: none;"> |
| <p class="rst-last"><span id="search-warn"></span></p> |
| </div> |
| |
| <table id="search-results"> |
| <!-- Filled dynamically by JS --> |
| </table> |
| |
| <div style="margin-top: 10px;"> |
| <p>For more information on the search, visit the <a href="apidocs-help.html#rst-search">help page</a>.</p> |
| </div> |
| </div> |
| |
| </div> |
| |
| |
| </div> |
| |
| |
| <!-- Side navigation --> |
| <div class="sidebarcontainer"> |
| <nav class="sidebar"> |
| |
| |
| <div> |
| |
| <div class="thingTitle"> |
| <span>Class</span> |
| <code class="thisobject"><a href="pulsar.Producer.html" class="internal-link" title="This class"><wbr></wbr>Producer</a></code> |
| </div> |
| |
| <div> |
| |
| |
| |
| |
| |
| |
| |
| |
| <div class="childrenKindTitle">Methods</div> |
| <ul> |
| |
| <li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#close" class="internal-link" title="pulsar.Producer.close">close</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#flush" class="internal-link" title="pulsar.Producer.flush">flush</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#is_connected" class="internal-link" title="pulsar.Producer.is_connected">is<wbr></wbr>_connected</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#last_sequence_id" class="internal-link" title="pulsar.Producer.last_sequence_id">last<wbr></wbr>_sequence<wbr></wbr>_id</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#producer_name" class="internal-link" title="pulsar.Producer.producer_name">producer<wbr></wbr>_name</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#send" class="internal-link" title="pulsar.Producer.send">send</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#send_async" class="internal-link" title="pulsar.Producer.send_async">send<wbr></wbr>_async</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#topic" class="internal-link" title="pulsar.Producer.topic">topic</a></code> |
| </div> |
| |
| |
| </li><li class="private"> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#_build_msg" class="internal-link" title="pulsar.Producer._build_msg">_build<wbr></wbr>_msg</a></code> |
| </div> |
| |
| |
| </li> |
| </ul> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| </div> |
| </div><div> |
| |
| <div class="thingTitle"> |
| <span>Package</span> |
| <code><a href="pulsar.html" class="internal-link" title="The parent of this class">pulsar</a></code> |
| </div> |
| |
| <div> |
| |
| |
| <div class="childrenKindTitle">Modules</div> |
| <ul> |
| |
| <li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.__about__.html" class="internal-link" title="pulsar.__about__">__about__</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.asyncio.html" class="internal-link" title="pulsar.asyncio">asyncio</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.exceptions.html" class="internal-link" title="pulsar.exceptions">exceptions</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.functions.html" class="internal-link" title="pulsar.functions">functions</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.schema.html" class="internal-link" title="pulsar.schema">schema</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.tableview.html" class="internal-link" title="pulsar.tableview">tableview</a></code> |
| </div> |
| |
| |
| </li> |
| </ul> |
| |
| <div class="childrenKindTitle">Classes</div> |
| <ul> |
| |
| <li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.Authentication.html" class="internal-link" title="pulsar.Authentication"><wbr></wbr>Authentication</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.AuthenticationAthenz.html" class="internal-link" title="pulsar.AuthenticationAthenz"><wbr></wbr>Authentication<wbr></wbr>Athenz</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.AuthenticationBasic.html" class="internal-link" title="pulsar.AuthenticationBasic"><wbr></wbr>Authentication<wbr></wbr>Basic</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.AuthenticationOauth2.html" class="internal-link" title="pulsar.AuthenticationOauth2"><wbr></wbr>Authentication<wbr></wbr>Oauth2</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.AuthenticationTLS.html" class="internal-link" title="pulsar.AuthenticationTLS"><wbr></wbr>Authentication<wbr></wbr>TLS</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.AuthenticationToken.html" class="internal-link" title="pulsar.AuthenticationToken"><wbr></wbr>Authentication<wbr></wbr>Token</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.AutoClusterFailover.html" class="internal-link" title="pulsar.AutoClusterFailover"><wbr></wbr>Auto<wbr></wbr>Cluster<wbr></wbr>Failover</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.Client.html" class="internal-link" title="pulsar.Client"><wbr></wbr>Client</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.ConsoleLogger.html" class="internal-link" title="pulsar.ConsoleLogger"><wbr></wbr>Console<wbr></wbr>Logger</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.Consumer.html" class="internal-link" title="pulsar.Consumer"><wbr></wbr>Consumer</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.ConsumerBatchReceivePolicy.html" class="internal-link" title="pulsar.ConsumerBatchReceivePolicy"><wbr></wbr>Consumer<wbr></wbr>Batch<wbr></wbr>Receive<wbr></wbr>Policy</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.ConsumerDeadLetterPolicy.html" class="internal-link" title="pulsar.ConsumerDeadLetterPolicy"><wbr></wbr>Consumer<wbr></wbr>Dead<wbr></wbr>Letter<wbr></wbr>Policy</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.ConsumerKeySharedPolicy.html" class="internal-link" title="pulsar.ConsumerKeySharedPolicy"><wbr></wbr>Consumer<wbr></wbr>Key<wbr></wbr>Shared<wbr></wbr>Policy</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.CryptoKeyReader.html" class="internal-link" title="pulsar.CryptoKeyReader"><wbr></wbr>Crypto<wbr></wbr>Key<wbr></wbr>Reader</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.EncryptionContext.html" class="internal-link" title="pulsar.EncryptionContext"><wbr></wbr>Encryption<wbr></wbr>Context</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.EncryptionKey.html" class="internal-link" title="pulsar.EncryptionKey"><wbr></wbr>Encryption<wbr></wbr>Key</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.FileLogger.html" class="internal-link" title="pulsar.FileLogger"><wbr></wbr>File<wbr></wbr>Logger</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.Message.html" class="internal-link" title="pulsar.Message"><wbr></wbr>Message</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.MessageBatch.html" class="internal-link" title="pulsar.MessageBatch"><wbr></wbr>Message<wbr></wbr>Batch</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.MessageId.html" class="internal-link" title="pulsar.MessageId"><wbr></wbr>Message<wbr></wbr>Id</a></code> |
| </div> |
| |
| |
| </li><li class=" thisobject"> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.Producer.html" class="internal-link" title="pulsar.Producer"><wbr></wbr>Producer</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.Reader.html" class="internal-link" title="pulsar.Reader"><wbr></wbr>Reader</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.ServiceInfo.html" class="internal-link" title="pulsar.ServiceInfo"><wbr></wbr>Service<wbr></wbr>Info</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.ServiceInfoProvider.html" class="internal-link" title="pulsar.ServiceInfoProvider"><wbr></wbr>Service<wbr></wbr>Info<wbr></wbr>Provider</a></code> |
| </div> |
| |
| |
| </li> |
| </ul> |
| |
| <div class="childrenKindTitle">Functions</div> |
| <ul> |
| |
| <li class="private"> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.html#_check_type" class="internal-link" title="pulsar._check_type">_check<wbr></wbr>_type</a></code> |
| </div> |
| |
| |
| </li><li class="private"> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.html#_check_type_or_none" class="internal-link" title="pulsar._check_type_or_none">_check<wbr></wbr>_type<wbr></wbr>_or<wbr></wbr>_none</a></code> |
| </div> |
| |
| |
| </li><li class="private"> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.html#_listener_wrapper" class="internal-link" title="pulsar._listener_wrapper">_listener<wbr></wbr>_wrapper</a></code> |
| </div> |
| |
| |
| </li><li class="private"> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.html#_seek_arg_convert" class="internal-link" title="pulsar._seek_arg_convert">_seek<wbr></wbr>_arg<wbr></wbr>_convert</a></code> |
| </div> |
| |
| |
| </li> |
| </ul> |
| |
| |
| |
| |
| <div class="childrenKindTitle">Variables</div> |
| <ul> |
| |
| <li class="private"> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="pulsar.html#_retype" class="internal-link" title="pulsar._retype">_retype</a></code> |
| </div> |
| |
| |
| </li> |
| </ul> |
| |
| |
| |
| |
| </div> |
| </div> |
| |
| </nav> |
| <!-- No sidebar toggle for read the docs theme, the sidebar is always |
| visible when the screen is width enough. |
| --> |
| </div> |
| |
| </nav> |
| |
| <div class="container-fluid"> |
| |
| <div id="main" class=""> |
| |
| |
| |
| |
| |
| <div class="page-header"> |
| <h1 class="class"><code><code><a href="pulsar.html" class="internal-link">pulsar</a></code><wbr></wbr>.<code><a href="pulsar.Producer.html" class="internal-link" title="pulsar.Producer">Producer</a></code></code></h1> |
| <div id="showPrivate"> |
| <button class="btn btn-link" onclick="togglePrivate()">Toggle Private API</button> |
| </div> |
| </div> |
| |
| <div class="categoryHeader"> |
| class documentation |
| </div> |
| |
| <div class="extrasDocstring"> |
| <p class="class-signature"><code><span class="py-keyword">class</span> <span class="py-defname">Producer</span>: <a href="https://github.com/apache/pulsar-client-python/tree/v3.11.0/pulsar/__init__.py#L1632" class="sourceLink">(source)</a></code></p> |
| <p><a href="classIndex.html#pulsar.Producer">View In Hierarchy</a></p> |
| </div> |
| |
| <div class="moduleDocstring"> |
| <div><p>The Pulsar message producer, used to publish messages on a topic.</p> |
| <div class="rst-admonition rst-admonition-examples"> |
| <p class="rst-admonition-title rst-first">Examples</p> |
| <pre class="py-doctest"> |
| <span class="py-keyword">import</span> pulsar |
| |
| client = pulsar.Client(<span class="py-string">'pulsar://localhost:6650'</span>) |
| producer = client.create_producer(<span class="py-string">'my-topic'</span>) |
| <span class="py-keyword">for</span> i <span class="py-keyword">in</span> <span class="py-builtin">range</span>(10): |
| producer.send((<span class="py-string">'Hello-%d'</span> % i).encode(<span class="py-string">'utf-8'</span>)) |
| client.close()</pre></div> |
| </div> |
| </div> |
| |
| <div id="splitTables"> |
| <table class="children sortable" id="id76"> |
| |
| |
| <tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#close" class="internal-link" title="pulsar.Producer.close">close</a></code></td> |
| <td>Close the producer.</td> |
| </tr><tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#flush" class="internal-link" title="pulsar.Producer.flush">flush</a></code></td> |
| <td>Flush all the messages buffered in the client and wait until all messages have been successfully persisted</td> |
| </tr><tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#is_connected" class="internal-link" title="pulsar.Producer.is_connected">is<wbr></wbr>_connected</a></code></td> |
| <td>Check if the producer is connected or not.</td> |
| </tr><tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#last_sequence_id" class="internal-link" title="pulsar.Producer.last_sequence_id">last<wbr></wbr>_sequence<wbr></wbr>_id</a></code></td> |
| <td>Get the last sequence id that was published by this producer.</td> |
| </tr><tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#producer_name" class="internal-link" title="pulsar.Producer.producer_name">producer<wbr></wbr>_name</a></code></td> |
| <td>Return the producer name which could have been assigned by the system or specified by the client</td> |
| </tr><tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#send" class="internal-link" title="pulsar.Producer.send">send</a></code></td> |
| <td>Publish a message on the topic. Blocks until the message is acknowledged</td> |
| </tr><tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#send_async" class="internal-link" title="pulsar.Producer.send_async">send<wbr></wbr>_async</a></code></td> |
| <td>Send a message asynchronously.</td> |
| </tr><tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#topic" class="internal-link" title="pulsar.Producer.topic">topic</a></code></td> |
| <td>Return the topic which producer is publishing to</td> |
| </tr><tr class="method private"> |
| |
| <td>Method</td> |
| <td><code><a href="#_build_msg" class="internal-link" title="pulsar.Producer._build_msg">_build<wbr></wbr>_msg</a></code></td> |
| <td><span class="rst-undocumented">Undocumented</span></td> |
| </tr> |
| </table> |
| |
| |
| |
| </div> |
| |
| <div id="childList"> |
| <div class="basemethod"> |
| |
| |
| <a name="pulsar.Producer.close"> |
| |
| </a> |
| <a name="close"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| |
| <span class="py-keyword">def</span> <span class="py-defname">close</span><span class="function-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span></span>):</span> |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.11.0/pulsar/__init__.py#L1817"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#close" title="pulsar.Producer.close"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Close the producer.</p></div> |
| </div> |
| </div><div class="basemethod"> |
| |
| |
| <a name="pulsar.Producer.flush"> |
| |
| </a> |
| <a name="flush"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| |
| <span class="py-keyword">def</span> <span class="py-defname">flush</span><span class="function-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span></span>):</span> |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.11.0/pulsar/__init__.py#L1809"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#flush" title="pulsar.Producer.flush"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Flush all the messages buffered in the client and wait until all messages have been |
| successfully persisted</p></div> |
| </div> |
| </div><div class="basemethod"> |
| |
| |
| <a name="pulsar.Producer.is_connected"> |
| |
| </a> |
| <a name="is_connected"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| |
| <span class="py-keyword">def</span> <span class="py-defname">is_connected</span><span class="function-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span></span>):</span> |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.11.0/pulsar/__init__.py#L1863"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#is_connected" title="pulsar.Producer.is_connected"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Check if the producer is connected or not.</p></div> |
| </div> |
| </div><div class="basemethod"> |
| |
| |
| <a name="pulsar.Producer.last_sequence_id"> |
| |
| </a> |
| <a name="last_sequence_id"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| |
| <span class="py-keyword">def</span> <span class="py-defname">last_sequence_id</span><span class="function-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span></span>):</span> |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.11.0/pulsar/__init__.py#L1663"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#last_sequence_id" title="pulsar.Producer.last_sequence_id"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Get the last sequence id that was published by this producer.</p> |
| <p>This represents either the automatically assigned or custom sequence id |
| (set on the <tt class="rst-docutils rst-literal">MessageBuilder</tt>) that was published and acknowledged by the broker.</p> |
| <p>After recreating a producer with the same producer name, this will return the |
| last message that was published in the previous producer session, or -1 if |
| there was no message ever published.</p> |
| </div> |
| </div> |
| </div><div class="basemethod"> |
| |
| |
| <a name="pulsar.Producer.producer_name"> |
| |
| </a> |
| <a name="producer_name"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| |
| <span class="py-keyword">def</span> <span class="py-defname">producer_name</span><span class="function-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span></span>):</span> |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.11.0/pulsar/__init__.py#L1656"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#producer_name" title="pulsar.Producer.producer_name"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Return the producer name which could have been assigned by the |
| system or specified by the client</p></div> |
| </div> |
| </div><div class="basemethod"> |
| |
| |
| <a name="pulsar.Producer.send"> |
| |
| </a> |
| <a name="send"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| |
| <span class="py-keyword">def</span> <span class="py-defname">send</span><span class="function-signature long-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span>, </span><span class="rst-sig-param">content, </span><span class="rst-sig-param">properties=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">partition_key=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">ordering_key=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">sequence_id=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">replication_clusters=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">disable_replication=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">event_timestamp=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">deliver_at=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">deliver_after=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a></span>) -> <code><a href="_pulsar.MessageId.html" class="internal-link" title="_pulsar.MessageId">_pulsar.MessageId</a></code>:</span> |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.11.0/pulsar/__init__.py#L1676"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#send" title="pulsar.Producer.send"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Publish a message on the topic. Blocks until the message is acknowledged</p> |
| <p>Returns a <code><a href="pulsar.MessageId.html" class="internal-link" title="pulsar.MessageId">MessageId</a></code> object that represents where the message is persisted.</p> |
| <table class="fieldTable"><tr class="fieldStart"><td class="fieldName" colspan="2">Parameters</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">content</span></td><td class="fieldArgDesc">A <tt class="rst-docutils rst-literal">bytes</tt> object with the message payload.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">properties:</span><em>optional</em></td><td class="fieldArgDesc">A dict of application-defined string properties.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">partition<wbr></wbr>_key:</span><em>optional</em></td><td class="fieldArgDesc">Sets the partition key for message routing. A hash of this key is used |
| to determine the message's topic partition.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">ordering<wbr></wbr>_key:</span><em>optional</em></td><td class="fieldArgDesc">Sets the ordering key for message routing.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">sequence<wbr></wbr>_id:</span><em>optional</em></td><td class="fieldArgDesc">Specify a custom sequence id for the message being published.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">replication<wbr></wbr>_clusters:</span><em>optional</em></td><td class="fieldArgDesc">Override namespace replication clusters. Note that it is the caller's responsibility to provide valid |
| cluster names and that all clusters have been previously configured as topics. Given an empty list, |
| the message will replicate according to the namespace configuration.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">disable<wbr></wbr>_replication:</span><code><a href="https://docs.python.org/3/library/functions.html#bool" class="intersphinx-link">bool</a></code>, <em>default</em> <code><a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a></code></td><td class="fieldArgDesc">Do not replicate this message.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">event<wbr></wbr>_timestamp:</span><em>optional</em></td><td class="fieldArgDesc">Timestamp in millis of the timestamp of event creation</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">deliver<wbr></wbr>_at:</span><em>optional</em></td><td class="fieldArgDesc">Specify the message should not be delivered earlier than the specified timestamp. |
| The timestamp is milliseconds and based on UTC</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">deliver<wbr></wbr>_after:</span><em>optional</em></td><td class="fieldArgDesc">Specify a delay in timedelta for the delivery of the messages.</td></tr></table><table class="fieldTable"><tr class="fieldStart"><td class="fieldName" colspan="2">Returns</td></tr><tr><td class="fieldArgContainer"><code><a href="_pulsar.MessageId.html" class="internal-link" title="_pulsar.MessageId">_pulsar.MessageId</a></code></td><td class="fieldArgDesc">A <code><a href="_pulsar.MessageId.html" class="internal-link">_pulsar.MessageId</a></code> object that represents where the message is persisted.</td></tr></table></div> |
| </div> |
| </div><div class="basemethod"> |
| |
| |
| <a name="pulsar.Producer.send_async"> |
| |
| </a> |
| <a name="send_async"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| |
| <span class="py-keyword">def</span> <span class="py-defname">send_async</span><span class="function-signature long-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span>, </span><span class="rst-sig-param">content, </span><span class="rst-sig-param">callback, </span><span class="rst-sig-param">properties=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">partition_key=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">ordering_key=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">sequence_id=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">replication_clusters=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">disable_replication=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">event_timestamp=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">deliver_at=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">deliver_after=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a></span>):</span> |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.11.0/pulsar/__init__.py#L1729"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#send_async" title="pulsar.Producer.send_async"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Send a message asynchronously.</p> |
| <div class="rst-admonition rst-admonition-examples"> |
| <p class="rst-admonition-title rst-first">Examples</p> |
| <p>The <tt class="rst-docutils rst-literal">callback</tt> will be invoked once the message has been acknowledged by the broker. |
| Users are responsible to handle the exception inside the callback. If any exception was |
| thrown from the callback, the process would terminate immediately.</p> |
| <pre class="py-doctest"> |
| <span class="py-keyword">import</span> pulsar |
| |
| client = pulsar.Client(<span class="py-string">'pulsar://localhost:6650'</span>) |
| producer = client.create_producer( |
| <span class="py-string">'my-topic'</span>, |
| block_if_queue_full=<span class="py-builtin">True</span>, |
| batching_enabled=<span class="py-builtin">True</span>, |
| batching_max_publish_delay_ms=10) |
| |
| <span class="py-keyword">def</span> <span class="py-defname">callback</span>(res, msg_id): |
| <span class="py-builtin">print</span>(<span class="py-string">'Message published res=%s'</span>, res) |
| |
| <span class="py-keyword">while</span> <span class="py-builtin">True</span>: |
| producer.send_async((<span class="py-string">'Hello-%d'</span> % i).encode(<span class="py-string">'utf-8'</span>), callback) |
| |
| client.close()</pre></div> |
| <p>When the producer queue is full, by default the message will be rejected |
| and the callback invoked with an error code.</p> |
| <table class="fieldTable"><tr class="fieldStart"><td class="fieldName" colspan="2">Parameters</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">content</span></td><td class="fieldArgDesc">A <code><a href="https://docs.python.org/3/library/stdtypes.html#bytes" class="intersphinx-link">bytes</a></code> object with the message payload.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">callback</span></td><td class="fieldArgDesc">A callback that is invoked once the message has been acknowledged by the broker.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">properties:</span><em>optional</em></td><td class="fieldArgDesc">A dict of application0-defined string properties.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">partition<wbr></wbr>_key:</span><em>optional</em></td><td class="fieldArgDesc">Sets the partition key for the message routing. A hash of this key is |
| used to determine the message's topic partition.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">ordering<wbr></wbr>_key:</span><em>optional</em></td><td class="fieldArgDesc">Sets the ordering key for the message routing.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">sequence<wbr></wbr>_id:</span><em>optional</em></td><td class="fieldArgDesc">Specify a custom sequence id for the message being published.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">replication<wbr></wbr>_clusters:</span><em>optional</em></td><td class="fieldArgDesc">Override namespace replication clusters. Note that it is the caller's responsibility |
| to provide valid cluster names and that all clusters have been previously configured |
| as topics. Given an empty list, the message will replicate per the namespace configuration.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">disable<wbr></wbr>_replication:</span><em>optional</em></td><td class="fieldArgDesc">Do not replicate this message.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">event<wbr></wbr>_timestamp:</span><em>optional</em></td><td class="fieldArgDesc">Timestamp in millis of the timestamp of event creation</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">deliver<wbr></wbr>_at:</span><em>optional</em></td><td class="fieldArgDesc">Specify the message should not be delivered earlier than the specified timestamp.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">deliver<wbr></wbr>_after:</span><em>optional</em></td><td class="fieldArgDesc">Specify a delay in timedelta for the delivery of the messages.</td></tr></table></div> |
| </div> |
| </div><div class="basemethod"> |
| |
| |
| <a name="pulsar.Producer.topic"> |
| |
| </a> |
| <a name="topic"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| |
| <span class="py-keyword">def</span> <span class="py-defname">topic</span><span class="function-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span></span>):</span> |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.11.0/pulsar/__init__.py#L1650"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#topic" title="pulsar.Producer.topic"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Return the topic which producer is publishing to</p></div> |
| </div> |
| </div><div class="basemethod private"> |
| |
| |
| <a name="pulsar.Producer._build_msg"> |
| |
| </a> |
| <a name="_build_msg"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| |
| <span class="py-keyword">def</span> <span class="py-defname">_build_msg</span><span class="function-signature long-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span>, </span><span class="rst-sig-param">content, </span><span class="rst-sig-param">properties, </span><span class="rst-sig-param">partition_key, </span><span class="rst-sig-param">ordering_key, </span><span class="rst-sig-param">sequence_id, </span><span class="rst-sig-param">replication_clusters, </span><span class="rst-sig-param">disable_replication, </span><span class="rst-sig-param">event_timestamp, </span><span class="rst-sig-param">deliver_at, </span><span class="rst-sig-param">deliver_after</span>):</span> |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.11.0/pulsar/__init__.py#L1823"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#_build_msg" title="pulsar.Producer._build_msg"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p class="undocumented">Undocumented</p></div> |
| </div> |
| </div> |
| </div> |
| |
| </div> |
| </div> |
| |
| <footer class="navbar navbar-default"> |
| <hr /> |
| |
| |
| <div class="container-fluid"> |
| <a href="index.html">API Documentation</a> for _pulsar/pulsar, |
| generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> |
| 25.4.0 at 2026-04-16 16:39:30. |
| </div> |
| |
| <script src="ajax.js" type="text/javascript"></script> |
| <script src="searchlib.js" type="text/javascript"></script> |
| <script src="search.js" type="text/javascript"></script> |
| |
| </footer> |
| |
| <script src="pydoctor.js" type="text/javascript"></script> |
| |
| </body> |
| </html> |