<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dmitry Kopytkov</title>
    <description>The latest articles on DEV Community by Dmitry Kopytkov (@piscesff).</description>
    <link>https://dev.to/piscesff</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4267441%2F3ecea704-0cf4-4ceb-97de-d8c8a1abb22d.png</url>
      <title>DEV Community: Dmitry Kopytkov</title>
      <link>https://dev.to/piscesff</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/piscesff"/>
    <language>en</language>
    <item>
      <title>You Shouldn't Need to Be a Kafka Expert to Consume Kafka</title>
      <dc:creator>Dmitry Kopytkov</dc:creator>
      <pubDate>Thu, 26 Nov 2026 17:55:28 +0000</pubDate>
      <link>https://dev.to/piscesff/you-shouldnt-need-to-be-a-kafka-expert-to-consume-kafka-35fi</link>
      <guid>https://dev.to/piscesff/you-shouldnt-need-to-be-a-kafka-expert-to-consume-kafka-35fi</guid>
      <description>&lt;p&gt;&lt;em&gt;Write an HTTP handler. Let WolveKafka manage Kafka consumption and delivery.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Ask a team to "just consume the &lt;code&gt;orders&lt;/code&gt; topic" and see how long it takes.&lt;/p&gt;

&lt;p&gt;The first version might be simple: read an order, check inventory, update a database.&lt;/p&gt;

&lt;p&gt;Then the inventory API goes down. A malformed order arrives. Your service gets more events than it can handle. Now you need retries, a place for failed records, and a way to slow delivery down.&lt;/p&gt;

&lt;p&gt;Every service ends up solving these problems alongside its business logic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;WolveKafka (WKS) moves that delivery work into a separate service.&lt;/strong&gt; It reads Kafka records and sends them to your application over HTTP. Your handler processes them and reports what happened. WKS handles the next step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Separate delivery from processing
&lt;/h2&gt;

&lt;p&gt;Dropbox describes a similar boundary in &lt;a href="https://dropbox.tech/infrastructure/infrastructure-messaging-system-model-async-platform-evolution" rel="noopener noreferrer"&gt;its post about evolving its async platform&lt;/a&gt;: delivery gets an event to a handler; execution is where the handler does the work.&lt;/p&gt;

&lt;p&gt;WKS applies that idea to Kafka. It manages the Kafka connection, consumer groups, and delivery policies. Your application decides what to do with each event.&lt;/p&gt;

&lt;p&gt;The two can change independently. You can update your order-processing code without rewriting a consumer loop. WKS is an independent project; the Dropbox post explains the broader architectural idea.&lt;/p&gt;

&lt;h2&gt;
  
  
  What your code looks like
&lt;/h2&gt;

&lt;p&gt;Your application exposes one HTTP endpoint. Here's a small Python example. Install Flask with &lt;code&gt;pip install flask&lt;/code&gt;, save this as &lt;code&gt;handler.py&lt;/code&gt;, and run &lt;code&gt;python handler.py&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;flask&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;base64&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Flask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__name__&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nd"&gt;@app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;handle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="n"&gt;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"messages"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;order&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;base64&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;b64decode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"value"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;order&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;                      &lt;span class="c1"&gt;# your business logic&lt;/span&gt;
        &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;     &lt;span class="c1"&gt;# 2 = SUCCESS, 0 = RETRY, 1 = FAILED&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s2"&gt;"messages"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;port&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;8081&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This handler prints each record and reports success. A real handler can return one of three results:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;SUCCESS&lt;/code&gt; (&lt;code&gt;2&lt;/code&gt;): processing succeeded.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;RETRY&lt;/code&gt; (&lt;code&gt;0&lt;/code&gt;): try this record again.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FAILED&lt;/code&gt; (&lt;code&gt;1&lt;/code&gt;): apply the configured dead-letter or drop action.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Return one result per record, in the same order. Always include the status: leaving it out means &lt;code&gt;RETRY&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For WKS running on the same host, this configuration points it at a local broker and the handler:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"cluster"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"bootstrap_servers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"localhost:9092"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nl"&gt;"consumers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"group_id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"orders-handler"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"topics"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"orders"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"lambdas"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;"url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"http://localhost:8081/"&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save it as &lt;code&gt;config.json&lt;/code&gt; and start a &lt;a href="https://github.com/wolveflake/wolvekafka/releases" rel="noopener noreferrer"&gt;released Linux binary&lt;/a&gt; with &lt;code&gt;wks --config_path config.json&lt;/code&gt;. In Docker, replace &lt;code&gt;localhost&lt;/code&gt; with addresses the container can reach. For a setup with everything included, use the demo below.&lt;/p&gt;

&lt;p&gt;Your application needs no Kafka client or consumer loop. The same HTTP contract works in any language that can serve HTTP.&lt;/p&gt;

&lt;h2&gt;
  
  
  Three bad days, handled
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The inventory API is down.&lt;/strong&gt; Your handler returns &lt;code&gt;RETRY&lt;/code&gt;. WKS waits and tries again according to your retry policy. If retries run out, it applies the dead-letter or drop action you configured. Without either action, it keeps retrying.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;An order is malformed.&lt;/strong&gt; Waiting won't fix it, so your handler returns &lt;code&gt;FAILED&lt;/code&gt;. WKS sends the original record to a configured dead-letter topic—a Kafka topic where failed records can be inspected later. Without a dead-letter or drop action, the batch stays uncommitted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your service is overloaded.&lt;/strong&gt; It returns HTTP &lt;code&gt;429&lt;/code&gt; with &lt;code&gt;Retry-After: 5&lt;/code&gt;. The WKS worker waits five seconds before retrying, without using up the records' retry budget. Other workers can still deliver, so configure concurrency to match your service's capacity.&lt;/p&gt;

&lt;p&gt;In each case &lt;strong&gt;your code reports the outcome, and WKS applies the delivery policy you chose.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Try it locally
&lt;/h2&gt;

&lt;p&gt;You need Git, Docker with Compose v2, Bash, and curl:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/wolveflake/wolvekafka.git
&lt;span class="nb"&gt;cd&lt;/span&gt; wolvekafka
./demo start --observe
./demo send &lt;span class="s1"&gt;'{"order_id":"123","event":"order.created"}'&lt;/span&gt;
./demo retry    &lt;span class="c"&gt;# watch a RETRY recover after backoff&lt;/span&gt;
./demo dlq      &lt;span class="c"&gt;# watch a FAILED record land in orders.dlq&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The demo runs Kafka, WKS, two Python handlers, Prometheus, and Grafana. It uses released WKS v0.2.0; newer features on &lt;code&gt;main&lt;/code&gt; require a source build. The first start downloads container images.&lt;/p&gt;

&lt;p&gt;Once the demo is running, open Grafana at &lt;code&gt;localhost:3000&lt;/code&gt; to see throughput, retries, and handler latency. Then replace &lt;code&gt;process_order&lt;/code&gt; in &lt;code&gt;examples/quickstart/handler.py&lt;/code&gt; with your own logic and run &lt;code&gt;./demo restart-handler&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Run &lt;code&gt;./demo stop&lt;/code&gt; when you're done.&lt;/p&gt;

&lt;h2&gt;
  
  
  What you still need to decide
&lt;/h2&gt;

&lt;p&gt;WKS removes consumer code from your application, but you still choose topics, access permissions, retry policies, and how many records to process at once. Someone also runs Kafka and WKS and monitors the backlog.&lt;/p&gt;

&lt;p&gt;Two delivery rules matter for your handler:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Records can arrive more than once.&lt;/strong&gt; Make repeated processing safe—for example, record an order ID together with its database update, and skip an update that's already been applied.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Parallel processing can change record order.&lt;/strong&gt; Choose batch mode when you need ordered processing within a partition.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;WKS commits Kafka offsets after the batch's outcomes and any required Kafka writes are complete. An unresolved record can therefore hold up other work in its worker. Set failure policies deliberately and monitor progress.&lt;/p&gt;

&lt;p&gt;WKS is early-stage software, available as Linux binaries, a container image, and a Helm chart. It's a fit for event processing in a service you deploy yourself. It doesn't provide stateful joins, windows, or exactly-once guarantees. If your existing consumer library already meets your needs, consider whether adding a delivery service is worthwhile.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where we use it
&lt;/h2&gt;

&lt;p&gt;In &lt;a href="https://wolveflake.io" rel="noopener noreferrer"&gt;Wolveflake's&lt;/a&gt; workflow architecture, WKS reads the workflow event log and sends batches to an HTTP dispatcher. The dispatcher loads the event, runs the workflow step, and reports the result. It contains no Kafka consumer code.&lt;/p&gt;

&lt;p&gt;If your team already knows what to do with an event, and you'd rather not become Kafka consumer experts to get it, give WKS a try.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/wolveflake/wolvekafka" rel="noopener noreferrer"&gt;Try WolveKafka on GitHub&lt;/a&gt;&lt;/strong&gt; — open source, Apache-2.0. What delivery problem has your team had to solve more than once? Share your use case in an issue or join us on &lt;a href="https://discord.gg/EPuXeJbG4j" rel="noopener noreferrer"&gt;Discord&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>kafka</category>
      <category>showdev</category>
      <category>opensource</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
