blob: f6b007e99c8ac9a266e31e4b3fe86a55f2fc900f [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.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 async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></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.kinesis module" href="apache_beam.io.kinesis.html" />
<link rel="prev" title="apache_beam.io.jdbc module" href="apache_beam.io.jdbc.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 current"><a class="reference internal" href="apache_beam.io.html">apache_beam.io package</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="apache_beam.io.html#subpackages">Subpackages</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="apache_beam.io.html#submodules">Submodules</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.avroio.html">apache_beam.io.avroio module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.concat_source.html">apache_beam.io.concat_source module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.debezium.html">apache_beam.io.debezium module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.filebasedsink.html">apache_beam.io.filebasedsink module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.filebasedsource.html">apache_beam.io.filebasedsource module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.fileio.html">apache_beam.io.fileio module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.filesystem.html">apache_beam.io.filesystem module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.filesystemio.html">apache_beam.io.filesystemio module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.filesystems.html">apache_beam.io.filesystems module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.hadoopfilesystem.html">apache_beam.io.hadoopfilesystem module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.iobase.html">apache_beam.io.iobase module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.jdbc.html">apache_beam.io.jdbc module</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">apache_beam.io.kafka module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.kinesis.html">apache_beam.io.kinesis module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.localfilesystem.html">apache_beam.io.localfilesystem module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.mongodbio.html">apache_beam.io.mongodbio module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.parquetio.html">apache_beam.io.parquetio module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.range_trackers.html">apache_beam.io.range_trackers module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.restriction_trackers.html">apache_beam.io.restriction_trackers module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.snowflake.html">apache_beam.io.snowflake module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.source_test_utils.html">apache_beam.io.source_test_utils module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.textio.html">apache_beam.io.textio module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.tfrecordio.html">apache_beam.io.tfrecordio module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.utils.html">apache_beam.io.utils module</a></li>
<li class="toctree-l3"><a class="reference internal" href="apache_beam.io.watermark_estimators.html">apache_beam.io.watermark_estimators module</a></li>
</ul>
</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.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>
</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>apache_beam.io.kafka module</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/apache_beam.io.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.kafka">
<span id="apache-beam-io-kafka-module"></span><h1>apache_beam.io.kafka module<a class="headerlink" href="#module-apache_beam.io.kafka" title="Permalink to this headline"></a></h1>
<dl class="docutils">
<dt>Unbounded source and sink transforms for</dt>
<dd><a class="reference external" href="href=&quot;http://kafka.apache.org/">Kafka</a>.</dd>
</dl>
<p>These transforms are currently supported by Beam portable runners (for
example, portable Flink and Spark) as well as Dataflow runner.</p>
<p><strong>Setup</strong></p>
<p>Transforms provided in this module are cross-language transforms
implemented in the Beam Java SDK. During the pipeline construction, Python SDK
will connect to a Java expansion service to expand these transforms.
To facilitate this, a small amount of setup is needed before using these
transforms in a Beam Python pipeline.</p>
<p>There are several ways to setup cross-language Kafka transforms.</p>
<ul class="simple">
<li>Option 1: use the default expansion service</li>
<li>Option 2: specify a custom expansion service</li>
</ul>
<p>See below for details regarding each of these options.</p>
<p><em>Option 1: Use the default expansion service</em></p>
<p>This is the recommended and easiest setup option for using Python Kafka
transforms. This option is only available for Beam 2.22.0 and later.</p>
<p>This option requires following pre-requisites before running the Beam
pipeline.</p>
<ul class="simple">
<li>Install Java runtime in the computer from where the pipeline is constructed
and make sure that ‘java’ command is available.</li>
</ul>
<p>In this option, Python SDK will either download (for released Beam version) or
build (when running from a Beam Git clone) a expansion service jar and use
that to expand transforms. Currently Kafka transforms use the
‘beam-sdks-java-io-expansion-service’ jar for this purpose.</p>
<p><em>Option 2: specify a custom expansion service</em></p>
<p>In this option, you startup your own expansion service and provide that as
a parameter when using the transforms provided in this module.</p>
<p>This option requires following pre-requisites before running the Beam
pipeline.</p>
<ul class="simple">
<li>Startup your own expansion service.</li>
<li>Update your pipeline to provide the expansion service address when
initiating Kafka transforms provided in this module.</li>
</ul>
<p>Flink Users can use the built-in Expansion Service of the Flink Runner’s
Job Server. If you start Flink’s Job Server, the expansion service will be
started on port 8097. For a different address, please set the
expansion_service parameter.</p>
<p><strong>More information</strong></p>
<p>For more information regarding cross-language transforms see:
- <a class="reference external" href="https://beam.apache.org/roadmap/portability/">https://beam.apache.org/roadmap/portability/</a></p>
<p>For more information specific to Flink runner see:
- <a class="reference external" href="https://beam.apache.org/documentation/runners/flink/">https://beam.apache.org/documentation/runners/flink/</a></p>
<dl class="class">
<dt id="apache_beam.io.kafka.ReadFromKafkaSchema">
<em class="property">class </em><code class="descclassname">apache_beam.io.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>, <em>start_read_time</em>, <em>max_num_records</em>, <em>max_read_time</em>, <em>commit_offset_in_finalize</em>, <em>timestamp_policy</em><span class="sig-paren">)</span><a class="headerlink" href="#apache_beam.io.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.9)"><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, start_read_time, max_num_records, max_read_time, commit_offset_in_finalize, timestamp_policy)</p>
<dl class="attribute">
<dt id="apache_beam.io.kafka.ReadFromKafkaSchema.commit_offset_in_finalize">
<code class="descname">commit_offset_in_finalize</code><a class="headerlink" href="#apache_beam.io.kafka.ReadFromKafkaSchema.commit_offset_in_finalize" title="Permalink to this definition"></a></dt>
<dd><p>Alias for field number 7</p>
</dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.kafka.ReadFromKafkaSchema.consumer_config">
<code class="descname">consumer_config</code><a class="headerlink" href="#apache_beam.io.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.kafka.ReadFromKafkaSchema.key_deserializer">
<code class="descname">key_deserializer</code><a class="headerlink" href="#apache_beam.io.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.kafka.ReadFromKafkaSchema.max_num_records">
<code class="descname">max_num_records</code><a class="headerlink" href="#apache_beam.io.kafka.ReadFromKafkaSchema.max_num_records" title="Permalink to this definition"></a></dt>
<dd><p>Alias for field number 5</p>
</dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.kafka.ReadFromKafkaSchema.max_read_time">
<code class="descname">max_read_time</code><a class="headerlink" href="#apache_beam.io.kafka.ReadFromKafkaSchema.max_read_time" title="Permalink to this definition"></a></dt>
<dd><p>Alias for field number 6</p>
</dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.kafka.ReadFromKafkaSchema.start_read_time">
<code class="descname">start_read_time</code><a class="headerlink" href="#apache_beam.io.kafka.ReadFromKafkaSchema.start_read_time" title="Permalink to this definition"></a></dt>
<dd><p>Alias for field number 4</p>
</dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.kafka.ReadFromKafkaSchema.timestamp_policy">
<code class="descname">timestamp_policy</code><a class="headerlink" href="#apache_beam.io.kafka.ReadFromKafkaSchema.timestamp_policy" title="Permalink to this definition"></a></dt>
<dd><p>Alias for field number 8</p>
</dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.kafka.ReadFromKafkaSchema.topics">
<code class="descname">topics</code><a class="headerlink" href="#apache_beam.io.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.kafka.ReadFromKafkaSchema.value_deserializer">
<code class="descname">value_deserializer</code><a class="headerlink" href="#apache_beam.io.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.kafka.default_io_expansion_service">
<code class="descclassname">apache_beam.io.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/kafka.html#default_io_expansion_service"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.kafka.default_io_expansion_service" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="class">
<dt id="apache_beam.io.kafka.ReadFromKafka">
<em class="property">class </em><code class="descclassname">apache_beam.io.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>start_read_time=None</em>, <em>max_num_records=None</em>, <em>max_read_time=None</em>, <em>commit_offset_in_finalize=False</em>, <em>timestamp_policy='ProcessingTime'</em>, <em>with_metadata=False</em>, <em>expansion_service=None</em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apache_beam/io/kafka.html#ReadFromKafka"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.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>Experimental; no backwards compatibility guarantees.</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>start_read_time</strong> – Use timestamp to set up start offset in milliseconds
epoch.</li>
<li><strong>max_num_records</strong> – Maximum amount of records to be read. Mainly used
for tests and demo applications.</li>
<li><strong>max_read_time</strong> – Maximum amount of time in seconds the transform
executes. Mainly used for tests and demo applications.</li>
<li><strong>commit_offset_in_finalize</strong> – Whether to commit offsets when finalizing.</li>
<li><strong>timestamp_policy</strong> – The built-in timestamp policy which is used for
extracting timestamp from KafkaRecord.</li>
<li><strong>with_metadata</strong> – whether the returned PCollection should contain
Kafka related metadata or not. If False (default), elements of the
returned PCollection will be of type ‘bytes’ if True, elements of the
returned PCollection will be of the type ‘Row’. Note that, currently
this only works when using default key and value deserializers where
Java Kafka Reader reads keys and values as ‘byte[]’.</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.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.kafka.ReadFromKafka.byte_array_deserializer" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.kafka.ReadFromKafka.processing_time_policy">
<code class="descname">processing_time_policy</code><em class="property"> = 'ProcessingTime'</em><a class="headerlink" href="#apache_beam.io.kafka.ReadFromKafka.processing_time_policy" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.kafka.ReadFromKafka.create_time_policy">
<code class="descname">create_time_policy</code><em class="property"> = 'CreateTime'</em><a class="headerlink" href="#apache_beam.io.kafka.ReadFromKafka.create_time_policy" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.kafka.ReadFromKafka.log_append_time">
<code class="descname">log_append_time</code><em class="property"> = 'LogAppendTime'</em><a class="headerlink" href="#apache_beam.io.kafka.ReadFromKafka.log_append_time" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.kafka.ReadFromKafka.URN_WITH_METADATA">
<code class="descname">URN_WITH_METADATA</code><em class="property"> = 'beam:external:java:kafkaio:externalwithmetadata:v1'</em><a class="headerlink" href="#apache_beam.io.kafka.ReadFromKafka.URN_WITH_METADATA" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.kafka.ReadFromKafka.URN_WITHOUT_METADATA">
<code class="descname">URN_WITHOUT_METADATA</code><em class="property"> = 'beam:external:java:kafkaio:typedwithoutmetadata:v1'</em><a class="headerlink" href="#apache_beam.io.kafka.ReadFromKafka.URN_WITHOUT_METADATA" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="apache_beam.io.kafka.WriteToKafkaSchema">
<em class="property">class </em><code class="descclassname">apache_beam.io.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.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.9)"><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.kafka.WriteToKafkaSchema.key_serializer">
<code class="descname">key_serializer</code><a class="headerlink" href="#apache_beam.io.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.kafka.WriteToKafkaSchema.producer_config">
<code class="descname">producer_config</code><a class="headerlink" href="#apache_beam.io.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.kafka.WriteToKafkaSchema.topic">
<code class="descname">topic</code><a class="headerlink" href="#apache_beam.io.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.kafka.WriteToKafkaSchema.value_serializer">
<code class="descname">value_serializer</code><a class="headerlink" href="#apache_beam.io.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.kafka.WriteToKafka">
<em class="property">class </em><code class="descclassname">apache_beam.io.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/kafka.html#WriteToKafka"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#apache_beam.io.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.</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.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.kafka.WriteToKafka.byte_array_serializer" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="apache_beam.io.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.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.kinesis.html" class="btn btn-neutral float-right" title="apache_beam.io.kinesis module" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="apache_beam.io.jdbc.html" class="btn btn-neutral float-left" title="apache_beam.io.jdbc 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>