blob: 711759d15611c362d1ed76109f0f99cbf976cb2d [file] [log] [blame]
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>apache_beam.io.external.kafka module &mdash; Apache Beam documentation</title>
<script type="text/javascript" src="_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/language_data.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="apache_beam.io.flink package" href="apache_beam.io.flink.html" />
<link rel="prev" title="apache_beam.io.external.generate_sequence module" href="apache_beam.io.external.generate_sequence.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home"> Apache Beam
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="apache_beam.coders.html">apache_beam.coders package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.dataframe.html">apache_beam.dataframe package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.internal.html">apache_beam.internal package</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="apache_beam.io.html">apache_beam.io package</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="apache_beam.io.html#subpackages">Subpackages</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.aws.html">apache_beam.io.aws package</a></li>
<li class="toctree-l3 current"><a class="reference internal" href="apache_beam.io.external.html">apache_beam.io.external package</a><ul class="current">
<li class="toctree-l4"><a class="reference internal" href="apache_beam.io.external.html#subpackages">Subpackages</a></li>
<li class="toctree-l4 current"><a class="reference internal" href="apache_beam.io.external.html#submodules">Submodules</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.flink.html">apache_beam.io.flink package</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.gcp.html">apache_beam.io.gcp package</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="apache_beam.io.html#submodules">Submodules</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.metrics.html">apache_beam.metrics package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.ml.html">apache_beam.ml package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.options.html">apache_beam.options package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.portability.html">apache_beam.portability package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.runners.html">apache_beam.runners package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.testing.html">apache_beam.testing package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.tools.html">apache_beam.tools package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.transforms.html">apache_beam.transforms package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.typehints.html">apache_beam.typehints package</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.utils.html">apache_beam.utils package</a></li>
</ul>
<ul>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.error.html">apache_beam.error module</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.pipeline.html">apache_beam.pipeline module</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.pvalue.html">apache_beam.pvalue module</a></li>
<li class="toctree-l1"><a class="reference internal" href="apache_beam.version.html">apache_beam.version module</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">Apache Beam</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> &raquo;</li>
<li><a href="apache_beam.io.html">apache_beam.io package</a> &raquo;</li>
<li><a href="apache_beam.io.external.html">apache_beam.io.external package</a> &raquo;</li>
<li>apache_beam.io.external.kafka module</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/apache_beam.io.external.kafka.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="module-apache_beam.io.external.kafka">
<span id="apache-beam-io-external-kafka-module"></span><h1>apache_beam.io.external.kafka module<a class="headerlink" href="#module-apache_beam.io.external.kafka" title="Permalink to this headline"></a></h1>
<p>PTransforms for supporting Kafka in Python pipelines. These transforms do not
run a Kafka client in Python. Instead, they expand to ExternalTransforms
which the Expansion Service resolves to the Java SDK’s KafkaIO. In other
words: they are cross-language transforms.</p>
<p>Note: To use these transforms, you need to start a Java Expansion Service.
Please refer to the portability documentation on how to do that. Flink Users
can use the built-in Expansion Service of the Flink Runner’s Job Server. The
expansion service address has to be provided when instantiating the
transforms.</p>
<p>If you start Flink’s Job Server, the expansion service will be started on
port 8097. This is also the configured default for this transform. For a
different address, please set the expansion_service parameter.</p>
<p>For more information see:
- <a class="reference external" href="https://beam.apache.org/documentation/runners/flink/">https://beam.apache.org/documentation/runners/flink/</a>
- <a class="reference external" href="https://beam.apache.org/roadmap/portability/">https://beam.apache.org/roadmap/portability/</a></p>
<dl class="class">
<dt id="apache_beam.io.external.kafka.ReadFromKafkaSchema">
<em class="property">class </em><code class="descclassname">apache_beam.io.external.kafka.</code><code class="descname">ReadFromKafkaSchema</code><span class="sig-paren">(</span><em>consumer_config</em>, <em>topics</em>, <em>key_deserializer</em>, <em>value_deserializer</em><span class="sig-paren">)</span><a class="headerlink" href="#apache_beam.io.external.kafka.ReadFromKafkaSchema" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a></p>
<p>Create new instance of ReadFromKafkaSchema(consumer_config, topics, key_deserializer, value_deserializer)</p>
<dl class="attribute">
<dt id="apache_beam.io.external.kafka.ReadFromKafkaSchema.consumer_config">
<code class="descname">consumer_config</code><a class="headerlink" href="#apache_beam.io.external.kafka.ReadFromKafkaSchema.consumer_config" title="Permalink to this definition"></a></dt>
<dd><p>Alias for field number 0</p>
</dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.external.kafka.ReadFromKafkaSchema.key_deserializer">
<code class="descname">key_deserializer</code><a class="headerlink" href="#apache_beam.io.external.kafka.ReadFromKafkaSchema.key_deserializer" title="Permalink to this definition"></a></dt>
<dd><p>Alias for field number 2</p>
</dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.external.kafka.ReadFromKafkaSchema.topics">
<code class="descname">topics</code><a class="headerlink" href="#apache_beam.io.external.kafka.ReadFromKafkaSchema.topics" title="Permalink to this definition"></a></dt>
<dd><p>Alias for field number 1</p>
</dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.external.kafka.ReadFromKafkaSchema.value_deserializer">
<code class="descname">value_deserializer</code><a class="headerlink" href="#apache_beam.io.external.kafka.ReadFromKafkaSchema.value_deserializer" title="Permalink to this definition"></a></dt>
<dd><p>Alias for field number 3</p>
</dd></dl>
</dd></dl>
<dl class="function">
<dt id="apache_beam.io.external.kafka.default_io_expansion_service">
<code class="descclassname">apache_beam.io.external.kafka.</code><code class="descname">default_io_expansion_service</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/external/kafka.html#default_io_expansion_service"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.external.kafka.default_io_expansion_service" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="class">
<dt id="apache_beam.io.external.kafka.ReadFromKafka">
<em class="property">class </em><code class="descclassname">apache_beam.io.external.kafka.</code><code class="descname">ReadFromKafka</code><span class="sig-paren">(</span><em>consumer_config</em>, <em>topics</em>, <em>key_deserializer='org.apache.kafka.common.serialization.ByteArrayDeserializer'</em>, <em>value_deserializer='org.apache.kafka.common.serialization.ByteArrayDeserializer'</em>, <em>expansion_service=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/external/kafka.html#ReadFromKafka"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.external.kafka.ReadFromKafka" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="apache_beam.transforms.external.html#apache_beam.transforms.external.ExternalTransform" title="apache_beam.transforms.external.ExternalTransform"><code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.transforms.external.ExternalTransform</span></code></a></p>
<p>An external PTransform which reads from Kafka and returns a KV pair for
each item in the specified Kafka topics. If no Kafka Deserializer for
key/value is provided, then the data will be returned as a raw byte array.</p>
<p>Note: Runners need to support translating Read operations in order to use
this source. At the moment only the Flink Runner supports this.</p>
<p>Experimental; no backwards compatibility guarantees. It requires special
preparation of the Java SDK. See BEAM-7870.</p>
<p>Initializes a read operation from Kafka.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>consumer_config</strong> – A dictionary containing the consumer configuration.</li>
<li><strong>topics</strong> – A list of topic strings.</li>
<li><strong>key_deserializer</strong> – A fully-qualified Java class name of a Kafka
Deserializer for the topic’s key, e.g.
‘org.apache.kafka.common.
serialization.LongDeserializer’.
Default: ‘org.apache.kafka.common.
serialization.ByteArrayDeserializer’.</li>
<li><strong>value_deserializer</strong> – A fully-qualified Java class name of a Kafka
Deserializer for the topic’s value, e.g.
‘org.apache.kafka.common.
serialization.LongDeserializer’.
Default: ‘org.apache.kafka.common.
serialization.ByteArrayDeserializer’.</li>
<li><strong>expansion_service</strong> – The address (host:port) of the ExpansionService.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="apache_beam.io.external.kafka.ReadFromKafka.byte_array_deserializer">
<code class="descname">byte_array_deserializer</code><em class="property"> = 'org.apache.kafka.common.serialization.ByteArrayDeserializer'</em><a class="headerlink" href="#apache_beam.io.external.kafka.ReadFromKafka.byte_array_deserializer" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.external.kafka.ReadFromKafka.URN">
<code class="descname">URN</code><em class="property"> = 'beam:external:java:kafka:read:v1'</em><a class="headerlink" href="#apache_beam.io.external.kafka.ReadFromKafka.URN" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.io.external.kafka.WriteToKafkaSchema">
<em class="property">class </em><code class="descclassname">apache_beam.io.external.kafka.</code><code class="descname">WriteToKafkaSchema</code><span class="sig-paren">(</span><em>producer_config</em>, <em>topic</em>, <em>key_serializer</em>, <em>value_serializer</em><span class="sig-paren">)</span><a class="headerlink" href="#apache_beam.io.external.kafka.WriteToKafkaSchema" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a></p>
<p>Create new instance of WriteToKafkaSchema(producer_config, topic, key_serializer, value_serializer)</p>
<dl class="attribute">
<dt id="apache_beam.io.external.kafka.WriteToKafkaSchema.key_serializer">
<code class="descname">key_serializer</code><a class="headerlink" href="#apache_beam.io.external.kafka.WriteToKafkaSchema.key_serializer" title="Permalink to this definition"></a></dt>
<dd><p>Alias for field number 2</p>
</dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.external.kafka.WriteToKafkaSchema.producer_config">
<code class="descname">producer_config</code><a class="headerlink" href="#apache_beam.io.external.kafka.WriteToKafkaSchema.producer_config" title="Permalink to this definition"></a></dt>
<dd><p>Alias for field number 0</p>
</dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.external.kafka.WriteToKafkaSchema.topic">
<code class="descname">topic</code><a class="headerlink" href="#apache_beam.io.external.kafka.WriteToKafkaSchema.topic" title="Permalink to this definition"></a></dt>
<dd><p>Alias for field number 1</p>
</dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.external.kafka.WriteToKafkaSchema.value_serializer">
<code class="descname">value_serializer</code><a class="headerlink" href="#apache_beam.io.external.kafka.WriteToKafkaSchema.value_serializer" title="Permalink to this definition"></a></dt>
<dd><p>Alias for field number 3</p>
</dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.io.external.kafka.WriteToKafka">
<em class="property">class </em><code class="descclassname">apache_beam.io.external.kafka.</code><code class="descname">WriteToKafka</code><span class="sig-paren">(</span><em>producer_config</em>, <em>topic</em>, <em>key_serializer='org.apache.kafka.common.serialization.ByteArraySerializer'</em>, <em>value_serializer='org.apache.kafka.common.serialization.ByteArraySerializer'</em>, <em>expansion_service=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/external/kafka.html#WriteToKafka"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.external.kafka.WriteToKafka" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <a class="reference internal" href="apache_beam.transforms.external.html#apache_beam.transforms.external.ExternalTransform" title="apache_beam.transforms.external.ExternalTransform"><code class="xref py py-class docutils literal notranslate"><span class="pre">apache_beam.transforms.external.ExternalTransform</span></code></a></p>
<p>An external PTransform which writes KV data to a specified Kafka topic.
If no Kafka Serializer for key/value is provided, then key/value are
assumed to be byte arrays.</p>
<p>Experimental; no backwards compatibility guarantees. It requires special
preparation of the Java SDK. See BEAM-7870.</p>
<p>Initializes a write operation to Kafka.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>producer_config</strong> – A dictionary containing the producer configuration.</li>
<li><strong>topic</strong> – A Kafka topic name.</li>
<li><strong>key_deserializer</strong> – A fully-qualified Java class name of a Kafka
Serializer for the topic’s key, e.g.
‘org.apache.kafka.common.
serialization.LongSerializer’.
Default: ‘org.apache.kafka.common.
serialization.ByteArraySerializer’.</li>
<li><strong>value_deserializer</strong> – A fully-qualified Java class name of a Kafka
Serializer for the topic’s value, e.g.
‘org.apache.kafka.common.
serialization.LongSerializer’.
Default: ‘org.apache.kafka.common.
serialization.ByteArraySerializer’.</li>
<li><strong>expansion_service</strong> – The address (host:port) of the ExpansionService.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<dl class="attribute">
<dt id="apache_beam.io.external.kafka.WriteToKafka.byte_array_serializer">
<code class="descname">byte_array_serializer</code><em class="property"> = 'org.apache.kafka.common.serialization.ByteArraySerializer'</em><a class="headerlink" href="#apache_beam.io.external.kafka.WriteToKafka.byte_array_serializer" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.external.kafka.WriteToKafka.URN">
<code class="descname">URN</code><em class="property"> = 'beam:external:java:kafka:write:v1'</em><a class="headerlink" href="#apache_beam.io.external.kafka.WriteToKafka.URN" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="apache_beam.io.flink.html" class="btn btn-neutral float-right" title="apache_beam.io.flink package" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="apache_beam.io.external.generate_sequence.html" class="btn btn-neutral float-left" title="apache_beam.io.external.generate_sequence module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
&copy; Copyright
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>