| <?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.Client</title> |
| <meta name="generator" content="pydoctor 22.9.1"> |
| |
| </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 <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="search-help-button" title="Help" onclick="toggleSearchHelpText()"><img src="fonts/info.svg" alt="Help" /></a> |
| </span> |
| </div> |
| </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.Client.html" class="internal-link" title="This class"><wbr></wbr>Client</a></code> |
| </div> |
| |
| <div> |
| |
| |
| |
| |
| |
| |
| |
| |
| <div class="childrenKindTitle">Methods</div> |
| <ul> |
| |
| <li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#__init__" class="internal-link" title="pulsar.Client.__init__">__init__</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#close" class="internal-link" title="pulsar.Client.close">close</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#create_producer" class="internal-link" title="pulsar.Client.create_producer">create<wbr></wbr>_producer</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#create_reader" class="internal-link" title="pulsar.Client.create_reader">create<wbr></wbr>_reader</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#get_topic_partitions" class="internal-link" title="pulsar.Client.get_topic_partitions">get<wbr></wbr>_topic<wbr></wbr>_partitions</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#shutdown" class="internal-link" title="pulsar.Client.shutdown">shutdown</a></code> |
| </div> |
| |
| |
| </li><li class=""> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#subscribe" class="internal-link" title="pulsar.Client.subscribe">subscribe</a></code> |
| </div> |
| |
| |
| </li><li class="private"> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#_prepare_logger" class="internal-link" title="pulsar.Client._prepare_logger">_prepare<wbr></wbr>_logger</a></code> |
| </div> |
| |
| |
| </li> |
| </ul> |
| |
| |
| |
| |
| <div class="childrenKindTitle">Attributes</div> |
| <ul> |
| |
| <li class="private"> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#_client" class="internal-link" title="pulsar.Client._client">_client</a></code> |
| </div> |
| |
| |
| </li><li class="private"> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="#_consumers" class="internal-link" title="pulsar.Client._consumers">_consumers</a></code> |
| </div> |
| |
| |
| </li> |
| </ul> |
| |
| |
| |
| |
| </div> |
| </div><div> |
| |
| <div class="thingTitle"> |
| <span>Package</span> |
| <code><a href="index.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.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.__about__.html" class="internal-link" title="pulsar.__about__">__about__</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> |
| </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=" thisobject"> |
| |
| |
| |
| |
| |
| <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.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.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=""> |
| |
| |
| |
| |
| |
| <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> |
| </ul> |
| |
| <div class="childrenKindTitle">Functions</div> |
| <ul> |
| |
| <li class="private"> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="index.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="index.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="index.html#_listener_wrapper" class="internal-link" title="pulsar._listener_wrapper">_listener<wbr></wbr>_wrapper</a></code> |
| </div> |
| |
| |
| </li> |
| </ul> |
| |
| |
| |
| |
| <div class="childrenKindTitle">Variables</div> |
| <ul> |
| |
| <li class="private"> |
| |
| |
| |
| |
| |
| <div class="itemName"><code><a href="index.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 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 class="hint" id="search-help-box"> |
| <p class="rst-last"> |
| |
| Search bar offers the following options: |
| <ul> |
| <li> |
| <strong>Term presence.</strong> The below example searches for documents that |
| must contain “foo”, might contain “bar” and must not contain “baz”: <code>+foo bar -baz</code> |
| </li> |
| |
| <li> |
| <strong>Wildcards.</strong> The below example searches for documents with words beginning with “foo”: <code>foo*</code> |
| </li> |
| |
| <li> |
| <strong>Search in specific fields.</strong> The following search matches all objects |
| in "twisted.mail" that matches “search”: <code>+qname:twisted.mail.* +search</code> |
| |
| <p> |
| Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. |
| Last two fields are only applicable if "search in docstrings" is enabled. |
| </p> |
| </li> |
| |
| <li> |
| <strong>Fuzzy matches.</strong> The following search matches all documents |
| that have a word within 1 edit distance of “foo”: <code>foo~1</code> |
| </li> |
| </ul> |
| |
| </p> |
| </div> |
| |
| <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: 8px;"> |
| <p>Results provided by <a href="https://lunrjs.com">Lunr.js</a></p> |
| </div> |
| </div> |
| |
| <div class="page-header"> |
| <h1 class="class"><code><code><a href="index.html" class="internal-link">pulsar</a></code><wbr></wbr>.<code><a href="pulsar.Client.html" class="internal-link" title="pulsar.Client">Client</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><code><span class="py-keyword">class</span> <span class="py-defname">Client</span>: <a href="https://github.com/apache/pulsar-client-python/tree/v3.1.0/pulsar/__init__.py#L346" class="sourceLink">(source)</a></code></p> |
| <p><a href="classIndex.html#pulsar.Client">View In Hierarchy</a></p> |
| </div> |
| |
| <div class="moduleDocstring"> |
| <div><p>The Pulsar client. A single client instance can be used to create producers |
| and consumers on multiple topics.</p> |
| <p>The client will share the same connection pool and threads across all |
| producers and consumers.</p> |
| </div> |
| </div> |
| |
| <div id="splitTables"> |
| <table class="children sortable" id="id60"> |
| |
| |
| <tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#__init__" class="internal-link" title="pulsar.Client.__init__">__init__</a></code></td> |
| <td>Create a new Pulsar client instance.</td> |
| </tr><tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#close" class="internal-link" title="pulsar.Client.close">close</a></code></td> |
| <td>Close the client and all the associated producers and consumers</td> |
| </tr><tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#create_producer" class="internal-link" title="pulsar.Client.create_producer">create<wbr></wbr>_producer</a></code></td> |
| <td>Create a new producer on a given topic.</td> |
| </tr><tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#create_reader" class="internal-link" title="pulsar.Client.create_reader">create<wbr></wbr>_reader</a></code></td> |
| <td>Create a reader on a particular topic</td> |
| </tr><tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#get_topic_partitions" class="internal-link" title="pulsar.Client.get_topic_partitions">get<wbr></wbr>_topic<wbr></wbr>_partitions</a></code></td> |
| <td>Get the list of partitions for a given topic.</td> |
| </tr><tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#shutdown" class="internal-link" title="pulsar.Client.shutdown">shutdown</a></code></td> |
| <td>Perform immediate shutdown of Pulsar client.</td> |
| </tr><tr class="method"> |
| |
| <td>Method</td> |
| <td><code><a href="#subscribe" class="internal-link" title="pulsar.Client.subscribe">subscribe</a></code></td> |
| <td>Subscribe to the given topic and subscription combination.</td> |
| </tr><tr class="staticmethod private"> |
| |
| <td>Static Method</td> |
| <td><code><a href="#_prepare_logger" class="internal-link" title="pulsar.Client._prepare_logger">_prepare<wbr></wbr>_logger</a></code></td> |
| <td><span class="undocumented">Undocumented</span></td> |
| </tr><tr class="instancevariable private"> |
| |
| <td>Instance Variable</td> |
| <td><code><a href="#_client" class="internal-link" title="pulsar.Client._client">_client</a></code></td> |
| <td><span class="undocumented">Undocumented</span></td> |
| </tr><tr class="instancevariable private"> |
| |
| <td>Instance Variable</td> |
| <td><code><a href="#_consumers" class="internal-link" title="pulsar.Client._consumers">_consumers</a></code></td> |
| <td><span class="undocumented">Undocumented</span></td> |
| </tr> |
| </table> |
| |
| |
| |
| </div> |
| |
| <div id="childList"> |
| <div class="basemethod"> |
| |
| |
| <a name="pulsar.Client.__init__"> |
| |
| </a> |
| <a name="__init__"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| <span class="py-keyword">def</span> <span class="py-defname">__init__</span>(self, service_url, authentication=None, operation_timeout_seconds=30, io_threads=1, message_listener_threads=1, concurrent_lookup_requests=50000, log_conf_file_path=None, use_tls=False, tls_trust_certs_file_path=None, tls_allow_insecure_connection=False, tls_validate_hostname=False, logger=None, connection_timeout_ms=10000, listener_name=None): |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.1.0/pulsar/__init__.py#L355"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#__init__" title="pulsar.Client.__init__"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Create a new Pulsar client instance.</p> |
| <table class="fieldTable"><tr class="fieldStart"><td class="fieldName" colspan="2">Parameters</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">service<wbr></wbr>_url:</span><code>str</code></td><td class="fieldArgDesc">The Pulsar service url eg: pulsar://my-broker.com:6650/</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">authentication:</span><code><a href="pulsar.Authentication.html" class="internal-link" title="pulsar.Authentication">Authentication</a></code>, <em>optional</em></td><td class="fieldArgDesc"><p>Set the authentication provider to be used with the broker. Supported methods:</p> |
| <ul class="rst-simple"> |
| <li><code><a href="pulsar.AuthenticationTLS.html" class="internal-link" title="pulsar.AuthenticationTLS">AuthenticationTLS</a></code></li> |
| <li><code><a href="pulsar.AuthenticationToken.html" class="internal-link" title="pulsar.AuthenticationToken">AuthenticationToken</a></code></li> |
| <li><code><a href="pulsar.AuthenticationAthenz.html" class="internal-link" title="pulsar.AuthenticationAthenz">AuthenticationAthenz</a></code></li> |
| <li><code><a href="pulsar.AuthenticationOauth2.html" class="internal-link" title="pulsar.AuthenticationOauth2">AuthenticationOauth2</a></code></li> |
| </ul> |
| </td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">operation<wbr></wbr>_timeout<wbr></wbr>_seconds:</span><code>int</code>, <em>default</em> <span class="literal">30</span></td><td class="fieldArgDesc">Set timeout on client operations (subscribe, create producer, close, unsubscribe).</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">io<wbr></wbr>_threads:</span><code>int</code>, <em>default</em> <span class="literal">1</span></td><td class="fieldArgDesc">Set the number of IO threads to be used by the Pulsar client.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">message<wbr></wbr>_listener<wbr></wbr>_threads:</span><code>int</code>, <em>default</em> <span class="literal">1</span></td><td class="fieldArgDesc">Set the number of threads to be used by the Pulsar client when delivering messages through |
| message listener. The default is 1 thread per Pulsar client. If using more than 1 thread, |
| messages for distinct <tt class="rst-docutils literal"><span class="pre">message_listener``s</span> will be delivered in different threads, however a |
| single ``MessageListener</tt> will always be assigned to the same thread.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">concurrent<wbr></wbr>_lookup<wbr></wbr>_requests:</span><code>int</code>, <em>default</em> <span class="literal">50000</span></td><td class="fieldArgDesc">Number of concurrent lookup-requests allowed on each broker connection to prevent overload |
| on the broker.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">log<wbr></wbr>_conf<wbr></wbr>_file<wbr></wbr>_path:</span><code>str</code>, <em>optional</em></td><td class="fieldArgDesc">Initialize log4cxx from a configuration file.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">use<wbr></wbr>_tls:</span><code>bool</code>, <em>default</em> <code>False</code></td><td class="fieldArgDesc">Configure whether to use TLS encryption on the connection. This setting is deprecated. |
| TLS will be automatically enabled if the <tt class="rst-docutils literal">serviceUrl</tt> is set to <tt class="rst-docutils literal"><span class="pre">pulsar+ssl://</span></tt> or <tt class="rst-docutils literal"><span class="pre">https://</span></tt></td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">tls<wbr></wbr>_trust<wbr></wbr>_certs<wbr></wbr>_file<wbr></wbr>_path:</span><code>str</code>, <em>optional</em></td><td class="fieldArgDesc">Set the path to the trusted TLS certificate file. If empty defaults to certifi.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">tls<wbr></wbr>_allow<wbr></wbr>_insecure<wbr></wbr>_connection:</span><code>bool</code>, <em>default</em> <code>False</code></td><td class="fieldArgDesc">Configure whether the Pulsar client accepts untrusted TLS certificates from the broker.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">tls<wbr></wbr>_validate<wbr></wbr>_hostname:</span><code>bool</code>, <em>default</em> <code>False</code></td><td class="fieldArgDesc">Configure whether the Pulsar client validates that the hostname of the endpoint, |
| matches the common name on the TLS certificate presented by the endpoint.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">logger:</span><em>optional</em></td><td class="fieldArgDesc">Set a Python logger for this Pulsar client. Should be an instance of <code>logging.Logger</code>.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">connection<wbr></wbr>_timeout<wbr></wbr>_ms:</span><code>int</code>, <em>default</em> <span class="literal">10000</span></td><td class="fieldArgDesc">Set timeout in milliseconds on TCP connections.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">listener<wbr></wbr>_name:</span><code>str</code>, <em>optional</em></td><td class="fieldArgDesc">Listener name for lookup. Clients can use listenerName to choose one of the listeners as |
| the service URL to create a connection to the broker as long as the network is accessible. |
| <tt class="rst-docutils literal">advertisedListeners</tt> must be enabled in broker side.</td></tr></table></div> |
| </div> |
| </div><div class="basemethod"> |
| |
| |
| <a name="pulsar.Client.close"> |
| |
| </a> |
| <a name="close"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| <span class="py-keyword">def</span> <span class="py-defname">close</span>(self): |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.1.0/pulsar/__init__.py#L952"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#close" title="pulsar.Client.close"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Close the client and all the associated producers and consumers</p> |
| </div> |
| </div> |
| </div><div class="basemethod"> |
| |
| |
| <a name="pulsar.Client.create_producer"> |
| |
| </a> |
| <a name="create_producer"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| <span class="py-keyword">def</span> <span class="py-defname">create_producer</span>(self, topic, producer_name=None, schema=<a href="pulsar.schema.schema.BytesSchema.html" class="internal-link" title="pulsar.schema.schema.BytesSchema">schema.BytesSchema</a>(), initial_sequence_id=None, send_timeout_millis=30000, compression_type=CompressionType.NONE, max_pending_messages=1000, max_pending_messages_across_partitions=50000, block_if_queue_full=False, batching_enabled=False, batching_max_messages=1000, batching_max_allowed_size_in_bytes=128*1024, batching_max_publish_delay_ms=10, chunking_enabled=False, message_routing_mode=PartitionsRoutingMode.RoundRobinDistribution, lazy_start_partitioned_producers=False, properties=None, batching_type=BatchingType.Default, encryption_key=None, crypto_key_reader=None): |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.1.0/pulsar/__init__.py#L476"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#create_producer" title="pulsar.Client.create_producer"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Create a new producer on a given topic.</p> |
| <table class="fieldTable"><tr class="fieldStart"><td class="fieldName" colspan="2">Parameters</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">topic:</span><code>str</code></td><td class="fieldArgDesc">The topic name</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">producer<wbr></wbr>_name:</span><code>str</code>, <em>optional</em></td><td class="fieldArgDesc">Specify a name for the producer. If not assigned, the system will generate a globally unique name |
| which can be accessed with <code><a href="pulsar.Producer.html#producer_name" class="internal-link" title="pulsar.Producer.producer_name">Producer.producer_name()</a></code>. When specifying a name, it is app to the user |
| to ensure that, for a given topic, the producer name is unique across all Pulsar's clusters.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">schema:</span><code><a href="pulsar.schema.schema.Schema.html" class="internal-link" title="pulsar.schema.schema.Schema">pulsar.schema.Schema</a></code>, <em>default</em> <code><a href="pulsar.schema.schema.BytesSchema.html" class="internal-link" title="pulsar.schema.schema.BytesSchema">pulsar.schema.BytesSchema</a></code></td><td class="fieldArgDesc"><p>Define the schema of the data that will be published by this producer, e.g, |
| <tt class="rst-docutils literal">schema=JsonSchema(MyRecordClass)</tt>.</p> |
| <dl class="rst-docutils"> |
| <dt>The schema will be used for two purposes:</dt> |
| <dd><ul class="rst-first rst-last rst-simple"> |
| <li>Validate the data format against the topic defined schema</li> |
| <li>Perform serialization/deserialization between data and objects</li> |
| </ul> |
| </dd> |
| </dl> |
| </td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">initial<wbr></wbr>_sequence<wbr></wbr>_id:</span><code>int</code>, <em>optional</em></td><td class="fieldArgDesc">Set the baseline for the sequence ids for messages published by the producer. First message will be |
| using <tt class="rst-docutils literal">(initialSequenceId + 1)</tt> as its sequence id and subsequent messages will be assigned |
| incremental sequence ids, if not otherwise specified.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">send<wbr></wbr>_timeout<wbr></wbr>_millis:</span><code>int</code>, <em>default</em> <span class="literal">30000</span></td><td class="fieldArgDesc">If a message is not acknowledged by the server before the <tt class="rst-docutils literal">send_timeout</tt> expires, an error will be reported.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">compression<wbr></wbr>_type:</span><code>CompressionType</code>, <em>default</em> <code>CompressionType.NONE</code></td><td class="fieldArgDesc"><p>Set the compression type for the producer. By default, message payloads are not compressed.</p> |
| <p>Supported compression types:</p> |
| <ul class="rst-simple"> |
| <li>CompressionType.LZ4</li> |
| <li>CompressionType.ZLib</li> |
| <li>CompressionType.ZSTD</li> |
| <li>CompressionType.SNAPPY</li> |
| </ul> |
| <p>ZSTD is supported since Pulsar 2.3. Consumers will need to be at least at that release in order to |
| be able to receive messages compressed with ZSTD.</p> |
| <p>SNAPPY is supported since Pulsar 2.4. Consumers will need to be at least at that release in order to |
| be able to receive messages compressed with SNAPPY.</p> |
| </td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">max<wbr></wbr>_pending<wbr></wbr>_messages:</span><code>int</code>, <em>default</em> <span class="literal">1000</span></td><td class="fieldArgDesc">Set the max size of the queue holding the messages pending to receive an acknowledgment from the broker.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">max<wbr></wbr>_pending<wbr></wbr>_messages<wbr></wbr>_across<wbr></wbr>_partitions:</span><code>int</code>, <em>default</em> <span class="literal">50000</span></td><td class="fieldArgDesc">Set the max size of the queue holding the messages pending to receive an acknowledgment across partitions |
| from the broker.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">block<wbr></wbr>_if<wbr></wbr>_queue<wbr></wbr>_full:</span><code>bool</code>, <em>default</em> <code>False</code></td><td class="fieldArgDesc">Set whether <code><a href="pulsar.Producer.html#send_async" class="internal-link" title="pulsar.Producer.send_async">send_async</a></code> operations should block when the outgoing message queue is full.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">batching<wbr></wbr>_enabled</span></td><td class="fieldArgDesc"><span class="undocumented">Undocumented</span></td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">batching<wbr></wbr>_max<wbr></wbr>_messages</span></td><td class="fieldArgDesc"><span class="undocumented">Undocumented</span></td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">batching<wbr></wbr>_max<wbr></wbr>_allowed<wbr></wbr>_size<wbr></wbr>_in<wbr></wbr>_bytes</span></td><td class="fieldArgDesc"><span class="undocumented">Undocumented</span></td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">batching<wbr></wbr>_max<wbr></wbr>_publish<wbr></wbr>_delay<wbr></wbr>_ms</span></td><td class="fieldArgDesc"><span class="undocumented">Undocumented</span></td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">chunking<wbr></wbr>_enabled:</span><code>bool</code>, <em>default</em> <code>False</code></td><td class="fieldArgDesc">If message size is higher than allowed max publish-payload size by broker then chunking_enabled helps |
| producer to split message into multiple chunks and publish them to broker separately and in order. |
| So, it allows client to successfully publish large size of messages in pulsar.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">message<wbr></wbr>_routing<wbr></wbr>_mode:</span><code>PartitionsRoutingMode</code>, <em>default</em> <code>PartitionsRoutingMode.RoundRobinDistribution</code></td><td class="fieldArgDesc"><p>Set the message routing mode for the partitioned producer.</p> |
| <p>Supported modes:</p> |
| <ul class="rst-simple"> |
| <li><code>PartitionsRoutingMode.RoundRobinDistribution</code></li> |
| <li><code>PartitionsRoutingMode.UseSinglePartition</code>.</li> |
| </ul> |
| </td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">lazy<wbr></wbr>_start<wbr></wbr>_partitioned<wbr></wbr>_producers:</span><code>bool</code>, <em>default</em> <code>False</code></td><td class="fieldArgDesc"><p>This config affects producers of partitioned topics only. It controls whether producers register |
| and connect immediately to the owner broker of each partition or start lazily on demand. The internal |
| producer of one partition is always started eagerly, chosen by the routing policy, but the internal |
| producers of any additional partitions are started on demand, upon receiving their first message.</p> |
| <p>Using this mode can reduce the strain on brokers for topics with large numbers of partitions and when |
| the SinglePartition routing policy is used without keyed messages. Because producer connection can be |
| on demand, this can produce extra send latency for the first messages of a given partition.</p> |
| </td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">properties:</span><code>dict</code>, <em>optional</em></td><td class="fieldArgDesc">Sets the properties for the producer. The properties associated with a producer can be used for identify |
| a producer at broker side.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">batching<wbr></wbr>_type:</span><code>BatchingType</code>, <em>default</em> <code>BatchingType.Default</code></td><td class="fieldArgDesc"><p>Sets the batching type for the producer.</p> |
| <p>There are two batching type: DefaultBatching and KeyBasedBatching.</p> |
| <dl class="rst-docutils"> |
| <dt>DefaultBatching will batch single messages:</dt> |
| <dd>(k1, v1), (k2, v1), (k3, v1), (k1, v2), (k2, v2), (k3, v2), (k1, v3), (k2, v3), (k3, v3)</dd> |
| <dt>... into single batch message:</dt> |
| <dd>[(k1, v1), (k2, v1), (k3, v1), (k1, v2), (k2, v2), (k3, v2), (k1, v3), (k2, v3), (k3, v3)]</dd> |
| <dt>KeyBasedBatching will batch incoming single messages:</dt> |
| <dd>(k1, v1), (k2, v1), (k3, v1), (k1, v2), (k2, v2), (k3, v2), (k1, v3), (k2, v3), (k3, v3)</dd> |
| <dt>... into single batch message:</dt> |
| <dd>[(k1, v1), (k1, v2), (k1, v3)], [(k2, v1), (k2, v2), (k2, v3)], [(k3, v1), (k3, v2), (k3, v3)]</dd> |
| </dl> |
| </td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">encryption<wbr></wbr>_key:</span><code>str</code>, <em>optional</em></td><td class="fieldArgDesc">The key used for symmetric encryption, configured on the producer side</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">crypto<wbr></wbr>_key<wbr></wbr>_reader:</span><code><a href="pulsar.CryptoKeyReader.html" class="internal-link" title="pulsar.CryptoKeyReader">CryptoKeyReader</a></code>, <em>optional</em></td><td class="fieldArgDesc">Symmetric encryption class implementation, configuring public key encryption messages for the producer |
| and private key decryption messages for the consumer</td></tr></table></div> |
| </div> |
| </div><div class="basemethod"> |
| |
| |
| <a name="pulsar.Client.create_reader"> |
| |
| </a> |
| <a name="create_reader"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| <span class="py-keyword">def</span> <span class="py-defname">create_reader</span>(self, topic, start_message_id, schema=<a href="pulsar.schema.schema.BytesSchema.html" class="internal-link" title="pulsar.schema.schema.BytesSchema">schema.BytesSchema</a>(), reader_listener=None, receiver_queue_size=1000, reader_name=None, subscription_role_prefix=None, is_read_compacted=False, crypto_key_reader=None): |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.1.0/pulsar/__init__.py#L818"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#create_reader" title="pulsar.Client.create_reader"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Create a reader on a particular topic</p> |
| <table class="fieldTable"><tr class="fieldStart"><td class="fieldName" colspan="2">Parameters</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">topic</span></td><td class="fieldArgDesc">The name of the topic.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">start<wbr></wbr>_message<wbr></wbr>_id</span></td><td class="fieldArgDesc"><p>The initial reader positioning is done by specifying a message id. The options are:</p> |
| <ul class="rst-simple"> |
| <li><tt class="rst-docutils literal">MessageId.earliest</tt>:</li> |
| </ul> |
| <p>Start reading from the earliest message available in the topic</p> |
| <ul class="rst-simple"> |
| <li><tt class="rst-docutils literal">MessageId.latest</tt>:</li> |
| </ul> |
| <p>Start reading from the end topic, only getting messages published after the reader was created</p> |
| <ul class="rst-simple"> |
| <li><tt class="rst-docutils literal">MessageId</tt>:</li> |
| </ul> |
| <p>When passing a particular message id, the reader will position itself on that specific position. |
| The first message to be read will be the message next to the specified messageId. |
| Message id can be serialized into a string and deserialized back into a <code><a href="pulsar.MessageId.html" class="internal-link" title="pulsar.MessageId">MessageId</a></code> object:</p> |
| <blockquote> |
| <pre class="py-doctest"> |
| <span class="py-comment"># Serialize to string</span> |
| s = msg.message_id().serialize() |
| |
| <span class="py-comment"># Deserialize from string</span> |
| msg_id = MessageId.deserialize(s)</pre></blockquote> |
| </td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">schema:</span><code><a href="pulsar.schema.schema.Schema.html" class="internal-link" title="pulsar.schema.schema.Schema">pulsar.schema.Schema</a></code>, <em>default</em> <code><a href="pulsar.schema.schema.BytesSchema.html" class="internal-link" title="pulsar.schema.schema.BytesSchema">pulsar.schema.BytesSchema</a></code></td><td class="fieldArgDesc">Define the schema of the data that will be received by this reader.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">reader<wbr></wbr>_listener:</span><em>optional</em></td><td class="fieldArgDesc"><p>Sets a message listener for the reader. When the listener is set, the application will receive messages |
| through it. Calls to <tt class="rst-docutils literal">reader.read_next()</tt> will not be allowed. The listener function needs to accept |
| (reader, message), for example:</p> |
| <pre class="py-doctest"> |
| <span class="py-keyword">def</span> <span class="py-defname">my_listener</span>(reader, message): |
| <span class="py-comment"># process message</span> |
| <span class="py-keyword">pass</span></pre></td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">receiver<wbr></wbr>_queue<wbr></wbr>_size:</span><code>int</code>, <em>default</em> <span class="literal">1000</span></td><td class="fieldArgDesc">Sets the size of the reader receive queue. The reader receive queue controls how many messages can be |
| accumulated by the reader before the application calls <code><a href="pulsar.Reader.html#read_next" class="internal-link" title="pulsar.Reader.read_next">read_next()</a></code>. Using a higher value could |
| potentially increase the reader throughput at the expense of higher memory utilization.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">reader<wbr></wbr>_name:</span><code>str</code>, <em>optional</em></td><td class="fieldArgDesc">Sets the reader name.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">subscription<wbr></wbr>_role<wbr></wbr>_prefix:</span><code>str</code>, <em>optional</em></td><td class="fieldArgDesc">Sets the subscription role prefix.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">is<wbr></wbr>_read<wbr></wbr>_compacted:</span><code>bool</code>, <em>default</em> <code>False</code></td><td class="fieldArgDesc">Selects whether to read the compacted version of the topic</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">crypto<wbr></wbr>_key<wbr></wbr>_reader:</span><code><a href="pulsar.CryptoKeyReader.html" class="internal-link" title="pulsar.CryptoKeyReader">CryptoKeyReader</a></code>, <em>optional</em></td><td class="fieldArgDesc">Symmetric encryption class implementation, configuring public key encryption messages for the producer |
| and private key decryption messages for the consumer</td></tr></table></div> |
| </div> |
| </div><div class="basemethod"> |
| |
| |
| <a name="pulsar.Client.get_topic_partitions"> |
| |
| </a> |
| <a name="get_topic_partitions"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| <span class="py-keyword">def</span> <span class="py-defname">get_topic_partitions</span>(self, topic): |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.1.0/pulsar/__init__.py#L919"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#get_topic_partitions" title="pulsar.Client.get_topic_partitions"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Get the list of partitions for a given topic.</p> |
| <p>If the topic is partitioned, this will return a list of partition names. If the topic is not |
| partitioned, the returned list will contain the topic name itself.</p> |
| <p>This can be used to discover the partitions and create Reader, Consumer or Producer |
| instances directly on a particular partition.</p> |
| <table class="fieldTable"><tr class="fieldStart"><td class="fieldName" colspan="2">Parameters</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">topic:</span><code>str</code></td><td class="fieldArgDesc">the topic name to lookup</td></tr><tr class="fieldStart"><td class="fieldName" colspan="2">Returns</td></tr><tr><td class="fieldArgContainer"><code>list</code></td><td class="fieldArgDesc">a list of partition name</td></tr></table></div> |
| </div> |
| </div><div class="basemethod"> |
| |
| |
| <a name="pulsar.Client.shutdown"> |
| |
| </a> |
| <a name="shutdown"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| <span class="py-keyword">def</span> <span class="py-defname">shutdown</span>(self): |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.1.0/pulsar/__init__.py#L943"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#shutdown" title="pulsar.Client.shutdown"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Perform immediate shutdown of Pulsar client.</p> |
| <p>Release all resources and close all producer, consumer, and readers without waiting |
| for ongoing operations to complete.</p> |
| </div> |
| </div> |
| </div><div class="basemethod"> |
| |
| |
| <a name="pulsar.Client.subscribe"> |
| |
| </a> |
| <a name="subscribe"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| <span class="py-keyword">def</span> <span class="py-defname">subscribe</span>(self, topic, subscription_name, consumer_type=ConsumerType.Exclusive, schema=<a href="pulsar.schema.schema.BytesSchema.html" class="internal-link" title="pulsar.schema.schema.BytesSchema">schema.BytesSchema</a>(), message_listener=None, receiver_queue_size=1000, max_total_receiver_queue_size_across_partitions=50000, consumer_name=None, unacked_messages_timeout_ms=None, broker_consumer_stats_cache_time_ms=30000, negative_ack_redelivery_delay_ms=60000, is_read_compacted=False, properties=None, pattern_auto_discovery_period=60, initial_position=InitialPosition.Latest, crypto_key_reader=None, replicate_subscription_state_enabled=False, max_pending_chunked_message=10, auto_ack_oldest_chunked_message_on_queue_full=False, start_message_id_inclusive=False, batch_receive_policy=None): |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.1.0/pulsar/__init__.py#L644"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#subscribe" title="pulsar.Client.subscribe"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p>Subscribe to the given topic and subscription combination.</p> |
| <table class="fieldTable"><tr class="fieldStart"><td class="fieldName" colspan="2">Parameters</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">topic</span></td><td class="fieldArgDesc">The name of the topic, list of topics or regex pattern. This method will accept these forms: |
| * <tt class="rst-docutils literal"><span class="pre">topic='my-topic'</span></tt> |
| * <tt class="rst-docutils literal"><span class="pre">topic=['topic-1',</span> <span class="pre">'topic-2',</span> <span class="pre">'topic-3']</span></tt> |
| * <tt class="rst-docutils literal"><span class="pre">topic=re.compile('persistent://public/default/topic-*')</span></tt></td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">subscription<wbr></wbr>_name:</span><code>str</code></td><td class="fieldArgDesc">The name of the subscription.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">consumer<wbr></wbr>_type:</span><code>ConsumerType</code>, <em>default</em> <code>ConsumerType.Exclusive</code></td><td class="fieldArgDesc">Select the subscription type to be used when subscribing to the topic.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">schema:</span><code><a href="pulsar.schema.schema.Schema.html" class="internal-link" title="pulsar.schema.schema.Schema">pulsar.schema.Schema</a></code>, <em>default</em> <code><a href="pulsar.schema.schema.BytesSchema.html" class="internal-link" title="pulsar.schema.schema.BytesSchema">pulsar.schema.BytesSchema</a></code></td><td class="fieldArgDesc">Define the schema of the data that will be received by this consumer.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">message<wbr></wbr>_listener:</span><em>optional</em></td><td class="fieldArgDesc"><p>Sets a message listener for the consumer. When the listener is set, the application will |
| receive messages through it. Calls to <tt class="rst-docutils literal">consumer.receive()</tt> will not be allowed. |
| The listener function needs to accept (consumer, message), for example:</p> |
| <pre class="py-doctest"> |
| <span class="py-keyword">def</span> <span class="py-defname">my_listener</span>(consumer, message): |
| <span class="py-comment"># process message</span> |
| consumer.acknowledge(message)</pre></td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">receiver<wbr></wbr>_queue<wbr></wbr>_size:</span><code>int</code>, <em>default</em> <span class="literal">1000</span></td><td class="fieldArgDesc"><p>Sets the size of the consumer receive queue. The consumer receive queue controls how many messages can be |
| accumulated by the consumer before the application calls <code><a href="pulsar.Consumer.html#receive" class="internal-link" title="pulsar.Consumer.receive">receive()</a></code>. Using a higher value could potentially |
| increase the consumer throughput at the expense of higher memory utilization. Setting the consumer queue |
| size to zero decreases the throughput of the consumer by disabling pre-fetching of messages.</p> |
| <p>This approach improves the message distribution on shared subscription by pushing messages only to those |
| consumers that are ready to process them. Neither receive with timeout nor partitioned topics can be used |
| if the consumer queue size is zero. The <code><a href="pulsar.Consumer.html#receive" class="internal-link" title="pulsar.Consumer.receive">receive()</a></code> function call should not be interrupted when the |
| consumer queue size is zero. The default value is 1000 messages and should work well for most use cases.</p> |
| </td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">max<wbr></wbr>_total<wbr></wbr>_receiver<wbr></wbr>_queue<wbr></wbr>_size<wbr></wbr>_across<wbr></wbr>_partitions:</span><code>int</code>, <em>default</em> <span class="literal">50000</span></td><td class="fieldArgDesc">Set the max total receiver queue size across partitions. This setting will be used to reduce the |
| receiver queue size for individual partitions</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">consumer<wbr></wbr>_name:</span><code>str</code>, <em>optional</em></td><td class="fieldArgDesc">Sets the consumer name.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">unacked<wbr></wbr>_messages<wbr></wbr>_timeout<wbr></wbr>_ms:</span><code>int</code>, <em>optional</em></td><td class="fieldArgDesc">Sets the timeout in milliseconds for unacknowledged messages. The timeout needs to be greater than |
| 10 seconds. An exception is thrown if the given value is less than 10 seconds. If a successful |
| acknowledgement is not sent within the timeout, all the unacknowledged messages are redelivered.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">broker<wbr></wbr>_consumer<wbr></wbr>_stats<wbr></wbr>_cache<wbr></wbr>_time<wbr></wbr>_ms:</span><code>int</code>, <em>default</em> <span class="literal">30000</span></td><td class="fieldArgDesc">Sets the time duration for which the broker-side consumer stats will be cached in the client.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">negative<wbr></wbr>_ack<wbr></wbr>_redelivery<wbr></wbr>_delay<wbr></wbr>_ms:</span><code>int</code>, <em>default</em> <span class="literal">60000</span></td><td class="fieldArgDesc">The delay after which to redeliver the messages that failed to be processed |
| (with the <tt class="rst-docutils literal">consumer.negative_acknowledge()</tt>)</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">is<wbr></wbr>_read<wbr></wbr>_compacted:</span><code>bool</code>, <em>default</em> <code>False</code></td><td class="fieldArgDesc">Selects whether to read the compacted version of the topic</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">properties:</span><code>dict</code>, <em>optional</em></td><td class="fieldArgDesc">Sets the properties for the consumer. The properties associated with a consumer can be used for |
| identify a consumer at broker side.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">pattern<wbr></wbr>_auto<wbr></wbr>_discovery<wbr></wbr>_period:</span><code>int</code>, <em>default</em> <span class="literal">60</span></td><td class="fieldArgDesc">Periods of seconds for consumer to auto discover match topics.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">initial<wbr></wbr>_position:</span><code>InitialPosition</code>, <em>default</em> <code>InitialPosition.Latest</code></td><td class="fieldArgDesc">Set the initial position of a consumer when subscribing to the topic. |
| It could be either: <code>InitialPosition.Earliest</code> or <code>InitialPosition.Latest</code>.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">crypto<wbr></wbr>_key<wbr></wbr>_reader:</span><code><a href="pulsar.CryptoKeyReader.html" class="internal-link" title="pulsar.CryptoKeyReader">CryptoKeyReader</a></code>, <em>optional</em></td><td class="fieldArgDesc">Symmetric encryption class implementation, configuring public key encryption messages for the producer |
| and private key decryption messages for the consumer</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">replicate<wbr></wbr>_subscription<wbr></wbr>_state<wbr></wbr>_enabled:</span><code>bool</code>, <em>default</em> <code>False</code></td><td class="fieldArgDesc">Set whether the subscription status should be replicated.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">max<wbr></wbr>_pending<wbr></wbr>_chunked<wbr></wbr>_message:</span><code>int</code>, <em>default</em> <span class="literal">10</span></td><td class="fieldArgDesc"><p>Consumer buffers chunk messages into memory until it receives all the chunks of the original message. |
| While consuming chunk-messages, chunks from same message might not be contiguous in the stream, and they |
| might be mixed with other messages' chunks. so, consumer has to maintain multiple buffers to manage |
| chunks coming from different messages. This mainly happens when multiple publishers are publishing |
| messages on the topic concurrently or publisher failed to publish all chunks of the messages.</p> |
| <p>If it's zero, the pending chunked messages will not be limited.</p> |
| </td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">auto<wbr></wbr>_ack<wbr></wbr>_oldest<wbr></wbr>_chunked<wbr></wbr>_message<wbr></wbr>_on<wbr></wbr>_queue<wbr></wbr>_full:</span><code>bool</code>, <em>default</em> <code>False</code></td><td class="fieldArgDesc">Buffering large number of outstanding uncompleted chunked messages can create memory pressure, and it |
| can be guarded by providing the maxPendingChunkedMessage threshold. See setMaxPendingChunkedMessage. |
| Once, consumer reaches this threshold, it drops the outstanding unchunked-messages by silently acking |
| if autoAckOldestChunkedMessageOnQueueFull is true else it marks them for redelivery.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">start<wbr></wbr>_message<wbr></wbr>_id<wbr></wbr>_inclusive:</span><code>bool</code>, <em>default</em> <code>False</code></td><td class="fieldArgDesc">Set the consumer to include the given position of any reset operation like Consumer::seek.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">batch<wbr></wbr>_receive<wbr></wbr>_policy:</span>class ConsumerBatchReceivePolicy</td><td class="fieldArgDesc">Set the batch collection policy for batch receiving.</td></tr></table></div> |
| </div> |
| </div><div class="basestaticmethod private"> |
| |
| |
| <a name="pulsar.Client._prepare_logger"> |
| |
| </a> |
| <a name="_prepare_logger"> |
| |
| </a> |
| <div class="functionHeader"> |
| @staticmethod<br /> |
| <span class="py-keyword">def</span> <span class="py-defname">_prepare_logger</span>(logger): |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.1.0/pulsar/__init__.py#L466"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#_prepare_logger" title="pulsar.Client._prepare_logger"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="docstring functionBody"> |
| |
| <div><p class="undocumented">Undocumented</p></div> |
| </div> |
| </div><div class="baseinstancevariable private"> |
| |
| |
| <a name="pulsar.Client._client"> |
| |
| </a> |
| <a name="_client"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| <span class="py-defname">_client</span> = |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.1.0/pulsar/__init__.py#L463"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#_client" title="pulsar.Client._client"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="functionBody"> |
| |
| <div><p class="undocumented">Undocumented</p></div> |
| |
| </div> |
| </div><div class="baseinstancevariable private"> |
| |
| |
| <a name="pulsar.Client._consumers"> |
| |
| </a> |
| <a name="_consumers"> |
| |
| </a> |
| <div class="functionHeader"> |
| |
| <span class="py-defname">_consumers</span>: <code>list</code> = |
| <a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.1.0/pulsar/__init__.py#L464"> |
| |
| (source) |
| </a> |
| <a class="headerLink" href="#_consumers" title="pulsar.Client._consumers"> |
| |
| |
| ¶ |
| </a> |
| </div> |
| <div class="functionBody"> |
| |
| <div><p class="undocumented">Undocumented</p></div> |
| |
| </div> |
| </div> |
| </div> |
| |
| </div> |
| </div> |
| |
| <footer class="navbar navbar-default"> |
| <hr /> |
| |
| |
| <div class="container"> |
| <a href="index.html">API Documentation</a> for pulsar, |
| generated by <a href="https://github.com/twisted/pydoctor/">pydoctor</a> |
| 22.9.1 at 2023-03-14 14:09:17. |
| </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> |