<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abhipranay Chauhan on Medium]]></title>
        <description><![CDATA[Stories by Abhipranay Chauhan on Medium]]></description>
        <link>https://medium.com/@abhipranay.chauhan?source=rss-fb295627c1e1------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*OIoFmG9-wDizNUdSULlC4g.png</url>
            <title>Stories by Abhipranay Chauhan on Medium</title>
            <link>https://medium.com/@abhipranay.chauhan?source=rss-fb295627c1e1------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 15:28:40 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@abhipranay.chauhan/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Beyond Naive RAG: Building a Fully Autonomous Multi-Agent SDLC]]></title>
            <link>https://medium.com/@abhipranay.chauhan/beyond-naive-rag-building-a-fully-autonomous-multi-agent-sdlc-6feffe33d354?source=rss-fb295627c1e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/6feffe33d354</guid>
            <dc:creator><![CDATA[Abhipranay Chauhan]]></dc:creator>
            <pubDate>Sun, 02 Aug 2026 20:19:37 GMT</pubDate>
            <atom:updated>2026-08-02T20:19:37.963Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve tried building an autonomous coding agent recently, you’ve probably hit the “Context Cliff.”</p><p>You feed your LLM a Jira ticket, point it at a vector database containing your codebase, and ask it to build a feature. What happens? It hallucinates dependencies, modifies the wrong User class because it couldn&#39;t distinguish the frontend interface from the backend ORM model, and instantly exhausts its 128k token window.</p><p>Naïve, chunk-based Vector RAG is a disaster for software engineering. Splitting code into 500-token chunks destroys structural scope, hides call hierarchies, and blinds the LLM to the broader system architecture.</p><p>To build a fully autonomous Software Development Life Cycle (SDLC) that scales across multiple microservices, repositories, and teams, we have to rethink how LLMs “see” code and how they execute tasks.</p><p>Here is the blueprint for an Enterprise Agentic Architecture using <strong>Global Service Graphs, AST Skeletonization, Multi-Agent Orchestration, and Harness Engineering</strong>.</p><h3>1. The Architecture: Two Brains are Better than One</h3><p>To solve complex software problems, a human engineer doesn’t just read code top-to-bottom. They first look at the system architecture (Which services are involved? Where is the database?), and <em>then</em> they zoom into specific files.</p><p>Our autonomous system needs the exact same capability. We achieve this by building a two-tiered graph architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A6gJVpZy-b_NjtVgg28Jqw.png" /><figcaption><em>Image 1: The Two-Tiered Agentic Knowledge Architecture.</em></figcaption></figure><h3>Tier 1: The Global Enterprise Graph</h3><p>We use the <strong>Backstage System Model</strong> stored in an in-memory graph database (like Memgraph). Every repository contains a catalog-info.yaml file. A CI/CD pipeline ingests these YAMLs to map the boundaries of your enterprise.</p><ul><li><strong>Why?</strong> Before writing a single line of code, the AI needs to know the “Blast Radius.” If it touches the Checkout API, it needs to know that the Search Indexer Cron Job will break.</li></ul><h3>Tier 2: The Local Code Property Graph (CPG)</h3><p>Inside a specific repository, we abandon standard text chunking. Instead, we use <strong>Tree-sitter</strong> to parse the Abstract Syntax Tree (AST). We store the <em>Call Graph</em> (which function calls which) in our Graph DB, and we create <strong>AST Skeletons</strong> (files with method bodies stripped out, leaving only signatures and docstrings) in our Vector DB.</p><ul><li><strong>Why?</strong> An agent can load the entire structural skeleton of a 100-file repository into its prompt for less than 5,000 tokens. It only requests the actual implementation code when it’s ready to edit.</li></ul><h3>2. Harness Engineering: Controlling the Execution</h3><p>Providing the right context (Context Engineering) is only half the battle. If you leave an LLM to freely generate code based on a graph, it will inevitably make mistakes, hallucinate syntax, or forget the initial goal halfway through a complex refactor.</p><p>To move from a prototype to a production system, we must apply <strong>Harness Engineering</strong>.</p><p>The “harness” is everything in the system <em>except</em> the LLM. It is the infrastructure that manages the lifecycle of the agent’s context, execution, and verification. While Prompt Engineering controls the words and Context Engineering controls the knowledge, <strong>Harness Engineering controls the execution.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qwMaUplYiZJWbwjUd98npw.png" /><figcaption><em>Image 2: The Agent Harness. The LLM is just the engine; the harness provides the steering and the brakes.</em></figcaption></figure><p>A robust agent harness for coding includes:</p><ol><li><strong>Computational Guides (Feedforward):</strong> Enforcing rules before the LLM generates code. For example, injecting the specific OpenRewrite recipe or architectural constraints (e.g., “the web layer cannot import the database layer”) directly into the agent’s prompt based on the repo it’s working in.</li><li><strong>Computational Sensors (Feedback):</strong> Deterministic verification loops. When the agent writes code, the harness automatically runs the compiler, type checkers, and structural tests. If it fails, the harness feeds the exact error message back into the LLM’s context window and triggers a retry.</li><li><strong>State Management:</strong> Agents are inherently stateless. The harness must track the task graph — what has been designed, what has been implemented, and what is currently failing. If a process takes 40 steps, the harness ensures the agent doesn’t “forget” step 20 when its context window cycles.</li></ol><h3>3. The Multi-Agent Swarm</h3><p>A single agent cannot hold the context of 5 different micro-services, nor can it manage the state of an entire cross-repository feature. To execute a full SDLC, we deploy a <strong>Swarm Architecture</strong> orchestrated by a Chief Architect Agent, wrapped in a robust harness.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cn5-JAeKA--deCjQmWjzLA.png" /><figcaption><em>Image 3: Multi-Agent Orchestration Swarm. The Architect plans; the Workers execute.</em></figcaption></figure><ul><li><strong>The Architect Agent:</strong> Has access to the Global Graph. It takes a ticket, queries the graph to find out which domains and services are impacted, drafts the cross-repo API contracts, and spawns workers.</li><li><strong>The Worker Agents:</strong> Confined to a single repository. They are equipped with Tree-sitter navigation tools to read AST skeletons, trace call hierarchies, and write localized code.</li><li><strong>The API Contract Broker:</strong> A shared memory space managed by the harness. If the Backend Worker changes a JSON response payload, the harness updates the broker, which instantly notifies the Frontend Worker to update its TypeScript interfaces.</li></ul><h3>4. Walking Through an Autonomous SDLC</h3><p>Let’s see how this system handles a real-world ticket: <strong>“Add a ‘Tax ID’ field to the User Profile.”</strong></p><h3>Phase 1: Discovery &amp; System Design (Architect Agent)</h3><p>The ticket is assigned to the Architect Agent. It doesn’t look at code. It looks at the <strong>Global Graph</strong>.</p><ol><li><strong>Tool Call:</strong> explore_neighbors(&quot;domain:user-management&quot;)</li><li><strong>Graph Response:</strong> The domain contains user-service (Backend) and profile-dashboard (Frontend). user-service depends on postgres-users-db.</li><li><strong>Tool Call:</strong> get_blast_radius(&quot;user-service-api&quot;)</li><li><strong>Graph Response:</strong> The billing-service consumes the user-service-api.</li></ol><p>The Architect now knows the plan: Update the DB schema, update the Backend API, update the Frontend UI, and ensure the Billing service doesn’t break.</p><h3>Phase 2: Delegation &amp; Skeletonization (Worker Agents)</h3><p>The Architect spawns a Backend Worker for user-service. The Worker uses the <strong>Local Code Property Graph</strong> to navigate, while the harness tracks its progress.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oqEiwdxh83Ij7vQmaqoYdA.png" /><figcaption><em>Image 4: The Worker Agent uses AST Skeletons to navigate locally without blowing up the context window.</em></figcaption></figure><h3>Phase 3: The Harness Feedback Loop</h3><p>The Backend Worker finishes adding the tax_id field. Before it can declare success, the Harness steps in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ByDw4ss1Ksdv8hsncCKZqw.png" /><figcaption><em>Image 5: The Harness Verification Loop. Agents self-heal failing code before proceeding.</em></figcaption></figure><p>The harness runs the local tests. If they fail, the agent is trapped in a self-correction loop until the tests pass. Only then does the harness flag the API Contract Broker that the payload has been successfully modified.</p><h3>Phase 4: Cross-Boundary Negotiation &amp; PR Compilation</h3><p>The Architect sees the broker update and pings the Frontend and Billing Workers:</p><blockquote>“Attention: user-service payload modified. tax_id (string) appended to UserProfile object. Update your local implementations.&quot;</blockquote><p>Once the Frontend and Billing Workers complete their tasks (and pass their own harness checks), the Architect Agent gathers the commits from all three workers, wraps them in a single, cohesive Jira update, and submits a linked, multi-repo Pull Request for human review.</p><h3>The Takeaway</h3><p>Throwing giant context windows at raw source code is a brute-force tactic that inevitably fails in enterprise environments.</p><p>By structuring your environment the way senior engineers structure their thinking — understanding domains, mapping dependencies, and reading interface skeletons before diving into implementations — and governing that process with robust Harness Engineering, you can build autonomous agents capable of truly impressive, multi-repository software development.</p><p><strong>The future of AI coding isn’t better text generation; it’s better knowledge representation and execution control.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6feffe33d354" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Kafka Exactly Once Semantics (EOS)]]></title>
            <link>https://engineering.hellofresh.com/demystifying-kafka-exactly-once-semantics-eos-390ae1c32bba?source=rss-fb295627c1e1------2</link>
            <guid isPermaLink="false">https://medium.com/p/390ae1c32bba</guid>
            <category><![CDATA[hellofresh]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[distributed-systems]]></category>
            <dc:creator><![CDATA[Abhipranay Chauhan]]></dc:creator>
            <pubDate>Tue, 05 Mar 2024 15:30:49 GMT</pubDate>
            <atom:updated>2024-03-05T15:30:49.079Z</atom:updated>
            <content:encoded><![CDATA[<p>— Co-Authors: <a href="https://medium.com/u/53affd7e0872">Konstantin Zhukov</a>, <a href="https://medium.com/u/b0a21e298f59">Madiyar</a>, <a href="https://medium.com/u/9d0a0f06558e">Muhammad Hamada</a>, <a href="https://medium.com/u/19eec5e298eb">Raouf Aghrout</a></p><p>At HelloFresh we use <strong>Kafka </strong>as a message broker for many backend services. It wouldn’t be an exaggeration to claim that every team is somehow dependent on <strong>Kafka </strong>for their services to work at scale.</p><p>Kafka is a highly performant and available message broker, which provides a wide range of features that can solve many complex problems for high traffic systems. <br>But “<em>With great power comes great responsibility</em><strong>”. </strong>Many of the sophisticated features provided by Kafka are sometimes misunderstood. One such feature is <strong>Exactly Once Semantics (EOS)</strong>, which is often confused with <strong>Exactly Once Delivery.</strong></p><p>I was trying to understand <strong>Exactly Once Semantics</strong> in Kafka, and failed to find any good articles which clarify how <strong>Exactly Once Semantics</strong> is different from <strong>Exactly Once Delivery</strong> and how Kafka implements <strong>Exactly Once Semantics</strong>. Also, instead of using a lot of jargon, I want to derive<strong> </strong>the implementation from basic concepts.</p><p>The aim of this article is to understand <strong>EOS </strong>in <strong>Kafka</strong>. This article is structured to provide clarity on the following points:</p><ol><li><strong>Exactly Once Semantics (EOS) != Exactly Once Delivery</strong></li><li>Is <strong>Exactly Once Delivery</strong> possible?</li><li>How does Kafka support <strong>EOS </strong>?<br>3.1 What are the boundaries/constraints within which EOS works?<br>3.2 Understanding the constructs used by Kafka to achieve EOS, derived from first principles.</li></ol><p><em>To keep this article short I haven’t included internal implementation details about Kafka transaction protocols. But those will be part of another article to be published in future.</em></p><p>Many of the software applications we use today require huge amounts of data and processing capabilities. It is costly and practically impossible to build a single computer which has huge resources and is easy to scale for future needs.</p><p>Instead it is the norm these days to build systems which utilize multiple lower resource computers, collaborating with each other via messages exchanged over a TCP/IP network, all while appearing as a single computer to the end user.</p><p>Such systems are commonly known as <a href="https://arc.net/l/quote/xmypyqcg">distributed systems</a>.</p><h4>Properties of real world distributed systems</h4><p>1. The components of a distributed system interact with one another in order to achieve a common goal.</p><p>2. Computers communicate by passing messages to each other over an unreliable network. (Unreliable means messages might be dropped by the network or due to network partition a message sent from one process to another might not reach the other end or might take an indefinite amount of time).</p><p>Messages take a non-zero amount of time to travel over the network.</p><p>3. Computers can become unavailable without telling other computers in the distributed system. Also processing each message will take a non-zero amount of time.</p><p>4. Computers can have heterogeneous resources (CPU, memory etc.) allocated to them.</p><p>5. Computers don’t have access to the internal state of each other. Messages are the only way via which one computer can know about the state of another computer.</p><h3>Let’s understand some terminology</h3><p>One of the hard problems of distributed systems (based on the constraints/properties described above) is <strong>Exactly Once Delivery</strong>.</p><p>We define the Exactly Once Delivery problem as follows: We have a sender that wants to send a message <strong>M</strong> to a receiver over an unreliable network. We want to make sure that the <strong>receiver receives the message M</strong> and <strong>receives it exactly one time</strong> despite the failures of the network.</p><p>With the above definition, an Exactly Once Delivery system should have the below properties for correctness and liveness:</p><ul><li>Correctness: The message is not <strong>delivered</strong> more than one time to the receiver.<br><em>Rejecting the message is not allowed, if the receiver has seen the message then it is considered delivered.</em></li><li>Liveness: The message is eventually delivered to the receiver.</li></ul><p>To achieve the above properties, the sender must know whether the receiver has received a message or not. If a message is received by the receiver then send another message, else retry the undelivered message.</p><p>Exactly Once Delivery can simplify a lot of operations. For example, say we want to build a system where sender A sends some numbers to receiver B, and B stores the numbers and also keeps updating a <strong>counter</strong> by adding the value received in the message.</p><p>With Exactly Once Delivery guarantees, building such a system is easy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*XkihWvmLNYprsId2" /></figure><p>Fig 1: System 1</p><p>Without Exactly Once Delivery guarantees building the above system might be non-trivial. It can be seen easily that A must not send any message twice as it can make the value of the <strong>counter </strong>inconsistent. So delivering a message only once is important.</p><p>Also, I want to highlight that a message is considered <strong>delivered </strong>if the receiver application ever saw the message. Any retry from the sender which makes the receiver application see the message again is considered a second delivery.</p><p>How will the sender know if <strong><em>message 1</em></strong> was seen by the receiver earlier so as to avoid sending it again? Simple, ask the receiver.</p><p>There is an assumption here that the receiver is storing some identifier (the message itself in this example) for the already received messages for indefinite time. Also, receiving the messages and storing the identifier is atomic.<br>Why atomic? Because if the receiver received the message but while storing the identifier the process failed then a second attempt will be required violating Exactly Once Delivery. You can imagine that achieving atomicity for the operation will be costly. Also it requires coordination from the receiver’s side. This solution will not scale well.</p><p>This leads to the theoretical impossibility of true <strong>Exactly Once Delivery</strong>.</p><p>Therefore for practical purposes and to lead the discussion in valuable direction I would like to introduce two terms:</p><p><strong>Effectively Once Delivery</strong> and <strong>Exactly Once Processing</strong></p><p>Taking the same system as above, we can redesign it like so:</p><p>A sends a message to B, and B stores a single copy of message <strong>M</strong> in a queue. If B receives message <strong>M </strong>again then it rejects it. This property is <strong>Effectively Once Delivery</strong>.</p><p>When <strong>B</strong> is updating the <strong>Counter</strong> (state change operation) then B must apply the update operation effectively once i.e. say the current state of B is S. Updating the <strong>Counter</strong> because of processing message M1 leads B to S`. Then B must process M1 in such a way that B transitions to state S`. This property is called <strong>Exactly Once Processing</strong> .</p><p>A combination of <strong>Effectively Once Delivery + Exactly Once Processing</strong> is what is desirable for practical distributed systems and is called <strong>Exactly Once Semantics</strong>.</p><p>Exactly Once Semantics != Exactly Once Delivery</p><p>Exactly Once Semantics = Effectively Once Delivery + Exactly Once Processing</p><p>For real world systems we are mostly looking for Exactly Once Semantics instead of Exactly Once Delivery.</p><p>Now our terminology is sorted, let’s see how <strong>Kafka</strong> achieves EOS.</p><h3>How Kafka supports Exactly Once Semantics</h3><p>Kafka applications (and Kafka itself) are distributed systems. Kafka applications involve different processes running on different computers.</p><ol><li>Producers</li><li>Broker(s). We might use Kafka Cluster and Kafka Brokers interchangeably for simplicity</li><li>Consumers</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*b8_lrxDs4sVxes1V" /></figure><p>Fig 2: Kafka application components</p><p><strong>What is processing cycle in Kafka?<br></strong>It is a read (from Kafka) → process → publish (to Kafka) cycle.</p><p>A producer writes a message to an <strong>input</strong> topic.<br>A consumer <strong>reads</strong> a message from the input topic, processes it and <strong>publishes</strong> it to the output topic.</p><p>Let’s see what are the different semantics offered by Kafka for the <strong>read → process → publish</strong> message processing cycle.</p><h4>1. At-Most Once Semantics</h4><p>For each input message there should be <strong>at most</strong> one output message.<br>Using the below sequence At-most once semantics can be achieved.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Tm-T_GljSqz1BjWz" /></figure><p>Fig 3</p><p>The system guarantees for At-Most Once Semantics:</p><p>1. Consumer applications never process a message twice.</p><p>2. Results for some input messages might be lost and are not guaranteed to be present on the output topic.</p><p><em>Why are a few processing results not present in the output topic?<br></em>Consider the situation when a consumer dies after committing an offset in step 2.<br>Kafka will not deliver the message again for processing as offset for it is already committed. So the result of processing the message is not present in the output topic.</p><p>This semantic is not useful when an application cannot tolerate loss of message processing.</p><h4>2. At-Least Once Semantics</h4><p>For each input message it is guaranteed to have at-least one output message.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*1UL0UfFT3xCGCll-" /></figure><p>Fig 4</p><p>This system guarantees for At-Least Once Semantics:</p><p>1. Duplicate processing results might be present in the output topic.</p><p>2. Loss of message processing results never happen.</p><p><em>Why might duplicate results be present in the output topic ?<br></em>Consider the scenario when a consumer dies after step 3 and before committing an offset to the broker.<br>When the consumer application will spawn again then it will read the uncommitted message again and will publish the result a second time to the output topic.</p><p>This message delivery semantic is undesirable for situations where receiving duplicate messages can lead to incorrect behavior of the system. Eg: System 1 in Fig 1 will have incorrect behavior using this semantic.</p><h4>3. Exactly Once Semantics</h4><p>For each input message one and only one output message is present in the output topic.</p><p>How can we achieve this?</p><p>Let’s try to change the ordering of various steps in the above 2 semantics.<br>Below is the topological sort for the above 4 step process</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*15YukmFg-TQ9GM94" /></figure><p>Fig 5</p><p>So the only flexible node is <strong>commit</strong> . There are 3 possibilities:</p><ol><li>Commit after Read == At-Most Once</li><li>Commit after Process == At-Most Once</li><li>Commit after Publish == At-Least Once</li></ol><p>So changing the order of steps doesn’t solve the problem. Also At-Most Once semantics are not an option since it can lead to loss of messages. So somehow we will have to build a solution on top of At-Least Once Semantics.</p><p>We can try to use some external persistent storage to keep track of which messages are already published to eliminate the problem of duplicates. But this solution is also faulty.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*cZufB2Y1RjIxOGrL" /></figure><p>Fig 6</p><p>What if in the above solution consumer B fails at step 3.2 which stores whether a message is published or not. <br>The message will be retried since it was not committed.<br>Step 2.1 will return false as no result was stored for the message and the process will move to step 3.1 resulting in a duplicate message in the output topic.</p><p>We can try any permutation of steps above but it will not solve the problem because of the distributed system constraints described at top of the article.</p><p>Let’s take a step back and think slowly.<br>Which problem do we want to solve? Duplicate reads by consumer or duplicate writes to output topic?<br>We can say that if there are no duplicate reads then there will be no duplicates to output topic.<br>Yes, this is correct. But without duplicate reads we will have some message loss as proven above.</p><p>Avoiding duplicate message reads == Exactly Once Delivery which is unavoidable as already established</p><p>If we think with focus we want to solve the duplicate output problem. If we have a single output then duplicate message delivery doesn’t matter. So let’s focus on solving the problem of duplicate publishing to the output topic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*oKXdAoDqiiSZiNTO" /></figure><p><strong>Idea: What if we can <em>publish</em> and <em>commit</em> offset Atomically in Kafka Broker?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*1-9WvpCL-4CT4Evl" /></figure><p>Steps to Exactly Once Semantics are as below:</p><ol><li>B reads a message from the broker.</li><li>B processes results<br>2.1 B starts a transaction</li><li>B publishes processed results to output-topic</li><li>B commits the offset of the input message</li><li>Transaction is committed or aborted (can be aborted by B or if B fails then the transaction is aborted by the broker due to transaction timeout)</li><li>On commit, the Kafka Broker will write to the output-topic and __consumer_offset topic atomically</li></ol><p>Let’s validate the above steps when, after publishing results to output-topic in step 3, the consumer fails to commit offset at step 4.<br>The transaction will be aborted and Kafka will mark the published result as hidden. <br>Kafka cannot delete a message because internally each topic is an append only log. And delete operations are not supported.</p><p>Kafka transactions can help us achieve Exactly Once Processing on the consumer side i.e. for read → process → publish cycle as long as the output is also produced to the same Kafka broker.</p><p>Transactions can be used to involve reading and writing to multiple partitions/topics atomically.</p><p>Until now we haven’t talked about the producer’s end. What if the producer produces duplicate messages in the input topic?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*YafleUBxn8KL1udx" /></figure><p>Why can there be duplicates in the input topic?<br>Consider the scenario where the Producer produces a message to the Broker. The Broker already wrote the message to the input topic. <br>When the Broker sends an ACK (receipt acknowledgment), a network partition happens and the producer will not receive the ACK.</p><p>Since the producer cannot inspect the state of the Broker to know whether a message was written to the Broker or not, it is bound to retry the message to avoid message loss.<br>This will lead to duplicate messages in the input topic.</p><p>This problem is easier to solve:</p><p>Say each producer attaches a monotonically increasing sequence id with each message. The Broker keeps track of the largest sequence ID per producer. Each producer is identified by an ID as well called PID or producer ID)</p><p>Whenever the Broker receives a message from the producer it checks if the sequence id is greater than the already seen sequence id for a given PID. If yes, then it appends the message in the log and updates sequence id, otherwise it ignores the message and sends back an ACK to the producer.</p><p>This is <strong>Effectively Once Delivery</strong> on the producer side.</p><p>This is called the idempotent producer protocol for Kafka. To use this just make the property <strong>enable.idempotence=true</strong> for the producer and <strong>ack=all</strong>.</p><h3>Summary</h3><p>Exactly Once Semantic = Effectively Once Delivery + Exactly Once Processing</p><p>Using an idempotent producer and transactions on the consumer end we achieved end to end Exactly Once Semantics in Kafka. This semantic is quite useful for Kafka stream applications.</p><p>Kafka Exactly Once Processing works only when input and output are both inside the same Kafka Broker. If applications have side effects like making changes to some external database, EOS doesn’t work for the whole pipeline.</p><p>Systems outside Kafka should be ready to handle duplicates since Exactly Once Delivery is not possible. Some kind of distributed transaction will be required between the Kafka broker and an external system, but achieving idempotent behavior usually costs less effort than distributed transactions.</p><h3>References</h3><p><a href="https://cwiki.apache.org/confluence/display/KAFKA/KIP-98+-+Exactly+Once+Delivery+and+Transactional+Messaging#KIP98ExactlyOnceDeliveryandTransactionalMessaging-ProposedChanges">KIP-98 — Exactly Once Delivery and Transactional Messaging — Apache Kafka — Apache Software Foundation</a></p><p><a href="https://cwiki.apache.org/confluence/display/KAFKA/KIP-98+-+Exactly+Once+Delivery+and+Transactional+Messaging#KIP98ExactlyOnceDeliveryandTransactionalMessaging-DataFlow">More detailed view of transaction protocol in kafka</a></p><p><a href="https://blog.acolyer.org/2015/04/22/distributed-snapshots-determining-global-states-of-distributed-systems/">Snapshot Marker ( Chandy &amp; Lamport )</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=390ae1c32bba" width="1" height="1" alt=""><hr><p><a href="https://engineering.hellofresh.com/demystifying-kafka-exactly-once-semantics-eos-390ae1c32bba">Demystifying Kafka Exactly Once Semantics (EOS)</a> was originally published in <a href="https://engineering.hellofresh.com/">HelloTech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>