[
https://issues.apache.org/jira/browse/KAFKA-6938?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16500970#comment-16500970
]
ASF GitHub Bot commented on KAFKA-6938:
---------------------------------------
guozhangwang closed pull request #5128: KAFKA-6938: Add documentation for
accessing Headers on Kafka Streams Processor API
URL: https://github.com/apache/kafka/pull/5128
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/docs/streams/developer-guide/processor-api.html
b/docs/streams/developer-guide/processor-api.html
index 8236ded5c82..e07efb16580 100644
--- a/docs/streams/developer-guide/processor-api.html
+++ b/docs/streams/developer-guide/processor-api.html
@@ -53,6 +53,7 @@
</ul>
</li>
<li><a class="reference internal"
href="#connecting-processors-and-state-stores" id="id8">Connecting Processors
and State Stores</a></li>
+ <li><a class="reference internal"
href="#accessing-processor-context" id="id10">Accessing Processor
Context</a></li>
</ul>
</div>
<div class="section" id="overview">
@@ -351,6 +352,22 @@ <h2>
your store.</p>
</div>
</div>
+ <div class="section" id="accessing-processor-context">
+ <h2><a class="toc-backref" href="#id10">Accessing Processor
Context</a><a class="headerlink" href="#accessing-processor-context"
title="Permalink to this headline"></a></h2>
+ <p>As we have mentioned in
<href=#defining-a-stream-processor>Defining a Stream Processor<\href>, a
<code>ProcessorContext</code> control the processing workflow, such as
scheduling a punctuation function, and committing the current processed
state.</p>
+ <p>This object can also be used to access the metadata related
with the application like
+ <code class="docutils literal"><span
class="pre">applicationId</span></code>, <code class="docutils literal"><span
class="pre">taskId</span></code>,
+ and <code class="docutils literal"><span
class="pre">stateDir</span></code>, and also record related metadata as <code
class="docutils literal"><span class="pre">topic</span></code>,
+ <code class="docutils literal"><span
class="pre">partition</span></code>, <code class="docutils literal"><span
class="pre">offset</span></code>, <code class="docutils literal"><span
class="pre">timestamp</span></code> and
+ <code class="docutils literal"><span
class="pre">headers</span></code>.</p>
+ <p>Here is an example implementation of how to add a new header to
the record:</p>
+ <div class="highlight-java"><div
class="highlight"><pre><span></span><span class="n">public void process(String
key, String value) {</span>
+
+ <span class="c1">// add a heaeder to the elements</span>
+ <span class="n">context()</span><span class="o">.</span><span
class="na">headers</span><span class="o">()</span><span class="o">.</span><span
class="na">add</span><span class="o">.</span><span class="o">(</span><span
class="s">"key"</span><span class="o">,</span> <span
class="s">"key"</span>
+ <span class="o">}</span>
+ </pre></div>
+ </div>
<div class="section" id="connecting-processors-and-state-stores">
<h2><a class="toc-backref" href="#id8">Connecting Processors and
State Stores</a><a class="headerlink"
href="#connecting-processors-and-state-stores" title="Permalink to this
headline"></a></h2>
<p>Now that a <a class="reference internal"
href="#streams-developer-guide-stream-processor"><span class="std
std-ref">processor</span></a> (WordCountProcessor) and the
@@ -399,8 +416,8 @@ <h2><a class="toc-backref" href="#id8">Connecting
Processors and State Stores</a
runtime, indicating the state store is not accessible from
this processor.</p>
<p>Now that you have fully defined your processor topology in your
application, you can proceed to
<a class="reference internal"
href="running-app.html#streams-developer-guide-execution"><span class="std
std-ref">running the Kafka Streams application</span></a>.</p>
-</div>
-</div>
+ </div>
+ </div>
</div>
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Add documentation for accessing Headers on Kafka Streams Processor API
> ----------------------------------------------------------------------
>
> Key: KAFKA-6938
> URL: https://issues.apache.org/jira/browse/KAFKA-6938
> Project: Kafka
> Issue Type: Improvement
> Components: documentation, streams
> Affects Versions: 2.0.0
> Reporter: Jorge Quilcate
> Assignee: Jorge Quilcate
> Priority: Major
> Fix For: 2.0.0
>
>
> Document changes implemented on KIP-244.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)