blob: 16f1c47ab1973f371d4f5a9441e05354ba937c84 [file]
<?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 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.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="#create_table_view" class="internal-link" title="pulsar.Client.create_table_view">create<wbr></wbr>_table<wbr></wbr>_view</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><li class="private">
<div class="itemName"><code><a href="#_table_view" class="internal-link" title="pulsar.Client._table_view">_table<wbr></wbr>_view</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=" 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.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.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="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.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 class="class-signature"><code><span class="py-keyword">class</span> <span class="py-defname">Client</span>: <a href="https://github.com/apache/pulsar-client-python/tree/v3.8.0/pulsar/__init__.py#L520" class="sourceLink">(source)</a></code></p><p>Constructor: <code><a href="#__init__" class="internal-link" title="pulsar.Client.__init__">Client(service_url, authentication, operation_timeout_seconds, io_threads, ...)</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="id69">
<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="#create_table_view" class="internal-link" title="pulsar.Client.create_table_view">create<wbr></wbr>_table<wbr></wbr>_view</a></code></td>
<td>Create a table view 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="rst-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="rst-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="rst-undocumented">Undocumented</span></td>
</tr><tr class="instancevariable private">
<td>Instance Variable</td>
<td><code><a href="#_table_view" class="internal-link" title="pulsar.Client._table_view">_table<wbr></wbr>_view</a></code></td>
<td><span class="rst-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>&#160;<span class="py-defname">__init__</span><span class="function-signature long-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span>, </span><span class="rst-sig-param">service_url, </span><span class="rst-sig-param">authentication=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">operation_timeout_seconds=30, </span><span class="rst-sig-param">io_threads=1, </span><span class="rst-sig-param">message_listener_threads=1, </span><span class="rst-sig-param">concurrent_lookup_requests=50000, </span><span class="rst-sig-param">log_conf_file_path=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">stats_interval_in_seconds=600, </span><span class="rst-sig-param">use_tls=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">tls_trust_certs_file_path=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">tls_allow_insecure_connection=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">tls_validate_hostname=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">logger=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">connection_timeout_ms=10000, </span><span class="rst-sig-param">listener_name=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">tls_private_key_file_path: <code><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a> | <a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a></code> = <a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">tls_certificate_file_path: <code><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a> | <a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a></code> = <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.8.0/pulsar/__init__.py#L529">
(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><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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 rst-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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></code>, <em>optional</em></td><td class="fieldArgDesc">This parameter is deprecated and makes no effect. It's retained only for compatibility.
Use <code>logger</code> to customize a logger.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">stats<wbr></wbr>_interval<wbr></wbr>_in<wbr></wbr>_seconds:</span><code><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></code>, <em>default</em> <span class="literal">600</span></td><td class="fieldArgDesc">Set the interval between each stats information update. Stats are printed and/or
passed to the statistics listener at this interval. Set to 0 to disable stats collection.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">use<wbr></wbr>_tls:</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">Configure whether to use TLS encryption on the connection. This setting is deprecated.
TLS will be automatically enabled if the <tt class="rst-docutils rst-literal">serviceUrl</tt> is set to <tt class="rst-docutils rst-literal"><span class="pre">pulsar+ssl://</span></tt> or <tt class="rst-docutils rst-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><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></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><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">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><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">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"><p>Set a Python logger for this Pulsar client. Should be an instance of <code><a href="https://docs.python.org/3/library/logging.html#logging.Logger" class="intersphinx-link">logging.Logger</a></code>.
It should be noted that if the Python logger is configured, during the termination of the Python
interpreter, the Python logger will be unavailable and the default logger will be used for logging.
To avoid strange behavior, you'd better delete all instances explicitly before exiting.</p>
<pre class="py-doctest">
<span class="py-keyword">import</span> logging
client = Client(service_url, logger=logging.getLogger(<span class="py-string">'pulsar'</span>))
producer = client.create_producer(topic)
<span class="py-comment"># ...</span>
<span class="py-keyword">del</span> producer
<span class="py-keyword">del</span> client</pre></td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">connection<wbr></wbr>_timeout<wbr></wbr>_ms:</span><code><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></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 rst-literal">advertisedListeners</tt> must be enabled in broker side.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">tls<wbr></wbr>_private<wbr></wbr>_key<wbr></wbr>_file<wbr></wbr>_path:</span><code><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></code>, <em>optional</em></td><td class="fieldArgDesc">The path to the TLS private key file</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">tls<wbr></wbr>_certificate<wbr></wbr>_file<wbr></wbr>_path:</span><code><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></code>, <em>optional</em></td><td class="fieldArgDesc">The path to the TLS certificate file.</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>&#160;<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.8.0/pulsar/__init__.py#L1301">
(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>&#160;<span class="py-defname">create_producer</span><span class="function-signature long-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span>, </span><span class="rst-sig-param">topic, </span><span class="rst-sig-param">producer_name=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">schema=<a href="pulsar.schema.schema.BytesSchema.html" class="internal-link" title="pulsar.schema.schema.BytesSchema">schema.BytesSchema</a>(), </span><span class="rst-sig-param">initial_sequence_id=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">send_timeout_millis=30000, </span><span class="rst-sig-param">compression_type: <code><a href="_pulsar.CompressionType.html" class="internal-link" title="_pulsar.CompressionType">CompressionType</a></code> = CompressionType.NONE, </span><span class="rst-sig-param">max_pending_messages=1000, </span><span class="rst-sig-param">max_pending_messages_across_partitions=50000, </span><span class="rst-sig-param">block_if_queue_full=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">batching_enabled=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">batching_max_messages=1000, </span><span class="rst-sig-param">batching_max_allowed_size_in_bytes=128 * 1024, </span><span class="rst-sig-param">batching_max_publish_delay_ms=10, </span><span class="rst-sig-param">chunking_enabled=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">message_routing_mode: <code><a href="_pulsar.PartitionsRoutingMode.html" class="internal-link" title="_pulsar.PartitionsRoutingMode">PartitionsRoutingMode</a></code> = PartitionsRoutingMode.RoundRobinDistribution, </span><span class="rst-sig-param">lazy_start_partitioned_producers=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </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">batching_type: <code><a href="_pulsar.BatchingType.html" class="internal-link" title="_pulsar.BatchingType">BatchingType</a></code> = BatchingType.Default, </span><span class="rst-sig-param">encryption_key=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">crypto_key_reader: <code><a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a> | <a href="pulsar.CryptoKeyReader.html" class="internal-link" title="pulsar.CryptoKeyReader">CryptoKeyReader</a></code> = <a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">access_mode: <code><a href="_pulsar.ProducerAccessMode.html" class="internal-link" title="_pulsar.ProducerAccessMode">ProducerAccessMode</a></code> = ProducerAccessMode.Shared, </span><span class="rst-sig-param">message_router: <code><a href="https://docs.python.org/3/library/typing.html#typing.Callable" class="intersphinx-link">Callable</a>[<wbr></wbr>[<wbr></wbr><a href="pulsar.Message.html" class="internal-link" title="pulsar.Message">Message</a>, <wbr></wbr><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a>], <wbr></wbr><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a>]</code> = <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.8.0/pulsar/__init__.py#L680">
(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><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></code></td><td class="fieldArgDesc">The topic name</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">producer<wbr></wbr>_name:</span><code><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></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 rst-literal">schema=JsonSchema(MyRecordClass)</tt>.</p>
<dl class="rst-docutils">
<dt>The schema will be used for two purposes:</dt>
<dd><ul class="rst-simple rst-first rst-last">
<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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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 rst-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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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 rst-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><a href="_pulsar.CompressionType.html" class="internal-link" title="_pulsar.CompressionType">CompressionType</a></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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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><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">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><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">When automatic batching is enabled, multiple calls to <code><a href="pulsar.Producer.html#send" class="internal-link" title="pulsar.Producer.send">send</a></code> can result in a single batch to be sent to the
broker, leading to better throughput, especially when publishing small messages.
All messages in a batch will be published as a single batched message. The consumer will be delivered
individual messages in the batch in the same order they were enqueued.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">batching<wbr></wbr>_max<wbr></wbr>_messages:</span><code><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></code>, <em>default</em> <span class="literal">1000</span></td><td class="fieldArgDesc">When you set this option to a value greater than 1, messages are queued until this threshold or
<code>batching_max_allowed_size_in_bytes</code> is reached or batch interval has elapsed.</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><code><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></code>, <em>default</em> 128*1024</td><td class="fieldArgDesc">When you set this option to a value greater than 1, messages are queued until this threshold or
<code>batching_max_messages</code> is reached or batch interval has elapsed.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">batching<wbr></wbr>_max<wbr></wbr>_publish<wbr></wbr>_delay<wbr></wbr>_ms:</span><code><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></code>, <em>default</em> <span class="literal">10</span></td><td class="fieldArgDesc">The batch interval in milliseconds. Queued messages will be sent in batch after this interval even if both
the threshold of <code>batching_max_messages</code> and <code>batching_max_allowed_size_in_bytes</code> are not reached.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">chunking<wbr></wbr>_enabled:</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">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><a href="_pulsar.PartitionsRoutingMode.html" class="internal-link" title="_pulsar.PartitionsRoutingMode">PartitionsRoutingMode</a></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><tt class="rst-docutils rst-literal">PartitionsRoutingMode.RoundRobinDistribution</tt></li>
<li><tt class="rst-docutils rst-literal">PartitionsRoutingMode.UseSinglePartition</tt></li>
</ul>
</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">lazy<wbr></wbr>_start<wbr></wbr>_partitioned<wbr></wbr>_producers:</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"><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><a href="https://docs.python.org/3/library/stdtypes.html#dict" class="intersphinx-link">dict</a></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><a href="_pulsar.BatchingType.html" class="internal-link" title="_pulsar.BatchingType">BatchingType</a></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><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></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><tr><td class="fieldArgContainer"><span class="fieldArg">access<wbr></wbr>_mode:</span><code><a href="_pulsar.ProducerAccessMode.html" class="internal-link" title="_pulsar.ProducerAccessMode">ProducerAccessMode</a></code>, <em>optional</em></td><td class="fieldArgDesc"><p>Set the type of access mode that the producer requires on the topic.</p>
<p>Supported modes:</p>
<ul class="rst-simple">
<li>Shared: By default multiple producers can publish on a topic.</li>
<li><dl class="rst-docutils rst-first">
<dt>Exclusive: Require exclusive access for producer.</dt>
<dd>Fail immediately if there's already a producer connected.</dd>
</dl>
</li>
<li>WaitForExclusive: Producer creation is pending until it can acquire exclusive access.</li>
<li><dl class="rst-docutils rst-first">
<dt>ExclusiveWithFencing: Acquire exclusive access for the producer.</dt>
<dd>Any existing producer will be removed and invalidated immediately.</dd>
</dl>
</li>
</ul>
</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">message<wbr></wbr>_router:</span><em>optional</em></td><td class="fieldArgDesc">A custom message router function that takes a <code><a href="pulsar.Message.html" class="internal-link" title="pulsar.Message">Message</a></code> and the number of partitions
and returns the partition index to which the message should be routed. If not provided,
the default routing policy defined by <code>message_routing_mode</code> will be used.</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>&#160;<span class="py-defname">create_reader</span><span class="function-signature long-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span>, </span><span class="rst-sig-param">topic, </span><span class="rst-sig-param">start_message_id, </span><span class="rst-sig-param">schema=<a href="pulsar.schema.schema.BytesSchema.html" class="internal-link" title="pulsar.schema.schema.BytesSchema">schema.BytesSchema</a>(), </span><span class="rst-sig-param">reader_listener=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">receiver_queue_size=1000, </span><span class="rst-sig-param">reader_name=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">subscription_role_prefix=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">is_read_compacted=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">crypto_key_reader: <code><a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a> | <a href="pulsar.CryptoKeyReader.html" class="internal-link" title="pulsar.CryptoKeyReader">CryptoKeyReader</a></code> = <a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">start_message_id_inclusive=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">crypto_failure_action: <code><a href="_pulsar.ConsumerCryptoFailureAction.html" class="internal-link" title="_pulsar.ConsumerCryptoFailureAction">ConsumerCryptoFailureAction</a></code> = ConsumerCryptoFailureAction.FAIL</span>):</span>
<a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.8.0/pulsar/__init__.py#L1109">
(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 rst-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 rst-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 rst-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 rst-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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></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><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></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><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">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><tr><td class="fieldArgContainer"><span class="fieldArg">start<wbr></wbr>_message<wbr></wbr>_id<wbr></wbr>_inclusive:</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">Set the reader to include the startMessageId or given position of any reset operation like Reader.seek</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">crypto<wbr></wbr>_failure<wbr></wbr>_action:</span><code><a href="_pulsar.ConsumerCryptoFailureAction.html" class="internal-link" title="_pulsar.ConsumerCryptoFailureAction">ConsumerCryptoFailureAction</a></code>, <em>default</em> <code>ConsumerCryptoFailureAction.FAIL</code></td><td class="fieldArgDesc"><p>Set the behavior when the decryption fails. The default is to fail the message.</p>
<p>Supported actions:</p>
<ul class="rst-simple">
<li>ConsumerCryptoFailureAction.FAIL: Fail consume until crypto succeeds</li>
<li>ConsumerCryptoFailureAction.DISCARD:
Message is silently acknowledged and not delivered to the application.</li>
<li>ConsumerCryptoFailureAction.CONSUME:
Deliver the encrypted message to the application. It's the application's responsibility
to decrypt the message. If message is also compressed, decompression will fail. If the
message contains batch messages, client will not be able to retrieve individual messages
in the batch.</li>
</ul>
</td></tr></table></div>
</div>
</div><div class="basemethod">
<a name="pulsar.Client.create_table_view">
</a>
<a name="create_table_view">
</a>
<div class="functionHeader">
<span class="py-keyword">def</span>&#160;<span class="py-defname">create_table_view</span><span class="function-signature long-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span>, </span><span class="rst-sig-param">topic: <code><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></code>, </span><span class="rst-sig-param">subscription_name: <code><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a> | <a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a></code> = <a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">schema: <code><a href="pulsar.schema.schema.Schema.html" class="internal-link" title="pulsar.schema.schema.Schema">schema.Schema</a></code> = <a href="pulsar.schema.schema.BytesSchema.html" class="internal-link" title="pulsar.schema.schema.BytesSchema">schema.BytesSchema</a>()</span>) -&gt; <code><a href="pulsar.tableview.TableView.html" class="internal-link" title="pulsar.tableview.TableView">TableView</a></code>:</span>
<a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.8.0/pulsar/__init__.py#L1232">
(source)
</a>
<a class="headerLink" href="#create_table_view" title="pulsar.Client.create_table_view">
</a>
</div>
<div class="docstring functionBody">
<div><p>Create a table view 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><code><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></code></td><td class="fieldArgDesc">The name of the topic.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">subscription<wbr></wbr>_name:</span><code><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></code>, <em>optional</em></td><td class="fieldArgDesc">The name of the subscription. If it's not specified, a random subscription name
will be used.</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 this table view. If the schema is incompatible with the topic's
schema, this method will throw an exception. This schema is also used to deserialize
the value of messages in the table view.</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.tableview.TableView.html" class="internal-link" title="pulsar.tableview.TableView">TableView</a></code></td><td class="fieldArgDesc">A table view instance.</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>&#160;<span class="py-defname">get_topic_partitions</span><span class="function-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span>, </span><span class="rst-sig-param">topic</span>):</span>
<a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.8.0/pulsar/__init__.py#L1268">
(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><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></code></td><td class="fieldArgDesc">the topic name to lookup</td></tr></table><table class="fieldTable"><tr class="fieldStart"><td class="fieldName" colspan="2">Returns</td></tr><tr><td class="fieldArgContainer"><code><a href="https://docs.python.org/3/library/stdtypes.html#list" class="intersphinx-link">list</a></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>&#160;<span class="py-defname">shutdown</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.8.0/pulsar/__init__.py#L1292">
(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>&#160;<span class="py-defname">subscribe</span><span class="function-signature long-signature">(<span class="rst-sig-param"><span class="rst-undocumented">self</span>, </span><span class="rst-sig-param">topic, </span><span class="rst-sig-param">subscription_name, </span><span class="rst-sig-param">consumer_type: <code><a href="_pulsar.ConsumerType.html" class="internal-link" title="_pulsar.ConsumerType">ConsumerType</a></code> = ConsumerType.Exclusive, </span><span class="rst-sig-param">schema=<a href="pulsar.schema.schema.BytesSchema.html" class="internal-link" title="pulsar.schema.schema.BytesSchema">schema.BytesSchema</a>(), </span><span class="rst-sig-param">message_listener=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">receiver_queue_size=1000, </span><span class="rst-sig-param">max_total_receiver_queue_size_across_partitions=50000, </span><span class="rst-sig-param">consumer_name=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">unacked_messages_timeout_ms=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">broker_consumer_stats_cache_time_ms=30000, </span><span class="rst-sig-param">negative_ack_redelivery_delay_ms=60000, </span><span class="rst-sig-param">is_read_compacted=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </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">pattern_auto_discovery_period=60, </span><span class="rst-sig-param">initial_position: <code><a href="_pulsar.InitialPosition.html" class="internal-link" title="_pulsar.InitialPosition">InitialPosition</a></code> = InitialPosition.Latest, </span><span class="rst-sig-param">crypto_key_reader: <code><a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a> | <a href="pulsar.CryptoKeyReader.html" class="internal-link" title="pulsar.CryptoKeyReader">CryptoKeyReader</a></code> = <a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">replicate_subscription_state_enabled=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">max_pending_chunked_message=10, </span><span class="rst-sig-param">auto_ack_oldest_chunked_message_on_queue_full=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">start_message_id_inclusive=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">batch_receive_policy=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">key_shared_policy=<a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">batch_index_ack_enabled=<a href="https://docs.python.org/3/library/constants.html#False" class="intersphinx-link">False</a>, </span><span class="rst-sig-param">regex_subscription_mode: <code><a href="_pulsar.RegexSubscriptionMode.html" class="internal-link" title="_pulsar.RegexSubscriptionMode">RegexSubscriptionMode</a></code> = RegexSubscriptionMode.PersistentOnly, </span><span class="rst-sig-param">dead_letter_policy: <code><a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a> | <a href="pulsar.ConsumerDeadLetterPolicy.html" class="internal-link" title="pulsar.ConsumerDeadLetterPolicy">ConsumerDeadLetterPolicy</a></code> = <a href="https://docs.python.org/3/library/constants.html#None" class="intersphinx-link">None</a>, </span><span class="rst-sig-param">crypto_failure_action: <code><a href="_pulsar.ConsumerCryptoFailureAction.html" class="internal-link" title="_pulsar.ConsumerCryptoFailureAction">ConsumerCryptoFailureAction</a></code> = ConsumerCryptoFailureAction.FAIL</span>):</span>
<a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.8.0/pulsar/__init__.py#L885">
(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 rst-literal"><span class="pre">topic='my-topic'</span></tt>
* <tt class="rst-docutils rst-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 rst-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><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></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><a href="_pulsar.ConsumerType.html" class="internal-link" title="_pulsar.ConsumerType">ConsumerType</a></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 rst-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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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><a href="https://docs.python.org/3/library/stdtypes.html#str" class="intersphinx-link">str</a></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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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 rst-literal">consumer.negative_acknowledge()</tt>)</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">is<wbr></wbr>_read<wbr></wbr>_compacted:</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">Selects whether to read the compacted version of the topic</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">properties:</span><code><a href="https://docs.python.org/3/library/stdtypes.html#dict" class="intersphinx-link">dict</a></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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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><a href="_pulsar.InitialPosition.html" class="internal-link" title="_pulsar.InitialPosition">InitialPosition</a></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: <tt class="rst-docutils rst-literal">InitialPosition.Earliest</tt> or <tt class="rst-docutils rst-literal">InitialPosition.Latest</tt>.</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><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">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><a href="https://docs.python.org/3/library/functions.html#int" class="intersphinx-link">int</a></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><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">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><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">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><tr><td class="fieldArgContainer"><span class="fieldArg">key<wbr></wbr>_shared<wbr></wbr>_policy:</span>class ConsumerKeySharedPolicy</td><td class="fieldArgDesc">Set the key shared policy for use when the ConsumerType is KeyShared.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">batch<wbr></wbr>_index<wbr></wbr>_ack<wbr></wbr>_enabled:</span>Enable the batch index acknowledgement.</td><td class="fieldArgDesc">It should be noted that this option can only work when the broker side also enables the batch index
acknowledgement. See the <code>acknowledgmentAtBatchIndexLevelEnabled</code> config in <code>broker.conf</code>.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">regex<wbr></wbr>_subscription<wbr></wbr>_mode:</span><code><a href="_pulsar.RegexSubscriptionMode.html" class="internal-link" title="_pulsar.RegexSubscriptionMode">RegexSubscriptionMode</a></code>, <em>optional</em></td><td class="fieldArgDesc"><p>Set the regex subscription mode for use when the topic is a regex pattern.</p>
<p>Supported modes:</p>
<ul class="rst-simple">
<li>PersistentOnly: By default only subscribe to persistent topics.</li>
<li>NonPersistentOnly: Only subscribe to non-persistent topics.</li>
<li>AllTopics: Subscribe to both persistent and non-persistent topics.</li>
</ul>
</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">dead<wbr></wbr>_letter<wbr></wbr>_policy:</span>class ConsumerDeadLetterPolicy</td><td class="fieldArgDesc">Set dead letter policy for consumer.
By default, some messages are redelivered many times, even to the extent that they can never be
stopped. By using the dead letter mechanism, messages have the max redelivery count, when they're
exceeding the maximum number of redeliveries. Messages are sent to dead letter topics and acknowledged
automatically.</td></tr><tr><td class="fieldArgContainer"><span class="fieldArg">crypto<wbr></wbr>_failure<wbr></wbr>_action:</span><code><a href="_pulsar.ConsumerCryptoFailureAction.html" class="internal-link" title="_pulsar.ConsumerCryptoFailureAction">ConsumerCryptoFailureAction</a></code>, <em>default</em> <code>ConsumerCryptoFailureAction.FAIL</code></td><td class="fieldArgDesc"><p>Set the behavior when the decryption fails. The default is to fail the message.</p>
<p>Supported actions:</p>
<ul class="rst-simple">
<li>ConsumerCryptoFailureAction.FAIL: Fail consume until crypto succeeds</li>
<li>ConsumerCryptoFailureAction.DISCARD:
Message is silently acknowledged and not delivered to the application.</li>
<li>ConsumerCryptoFailureAction.CONSUME:
Deliver the encrypted message to the application. It's the application's responsibility
to decrypt the message. If message is also compressed, decompression will fail. If the
message contains batch messages, client will not be able to retrieve individual messages
in the batch.</li>
</ul>
</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">
<div><span class="decorator">@<a href="https://docs.python.org/3/library/functions.html#staticmethod" class="intersphinx-link">staticmethod</a><br /></span></div>
<span class="py-keyword">def</span>&#160;<span class="py-defname">_prepare_logger</span><span class="function-signature">(<span class="rst-sig-param">logger</span>):</span>
<a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.8.0/pulsar/__init__.py#L670">
(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.8.0/pulsar/__init__.py#L667">
(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><a href="https://docs.python.org/3/library/stdtypes.html#list" class="intersphinx-link">list</a></code> =
<a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.8.0/pulsar/__init__.py#L668">
(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 class="baseinstancevariable private">
<a name="pulsar.Client._table_view">
</a>
<a name="_table_view">
</a>
<div class="functionHeader">
<span class="py-defname">_table_view</span> =
<a class="sourceLink" href="https://github.com/apache/pulsar-client-python/tree/v3.8.0/pulsar/__init__.py#L1265">
(source)
</a>
<a class="headerLink" href="#_table_view" title="pulsar.Client._table_view">
</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-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 2025-07-19 14:22:25.
</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>