October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Kafka Request-Reply: The Pattern You Must Build on Top

Kafka’s broker protocol correlates its own requests and responses. Application-level request/reply over topics requires an agreed reply destination, correlation value, and policies for timeouts and late replies.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Kafka correlates its own client-to-broker protocol requests and responses, but it does not automatically turn a business record published to a topic into an application request/reply conversation. For that, the requester and worker must agree on a reply destination, a correlation value, and what happens when a reply is late or never arrives.

Kafka has two different kinds of request and response

Kafka’s wire protocol is request/response: a client sends a protocol request to a broker, and the protocol uses a correlation ID to match the response with that request. Apache Kafka describes the exchange this way: “The client initiates a socket connection and then writes a sequence of request messages and reads back the corresponding response message.” Apache Kafka protocol documentation explains this transport-level conversation.

As an Amazon Associate I earn from qualifying purchases.

That correlation does not create a business-level reply when an application writes a record to a Kafka topic. A consumer may process that record, but the application must establish where any reply goes and how the requester recognizes it. The broker protocol’s correlation ID is not a substitute for those application rules.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How topic-level request/reply works

  1. Create a request. The requester publishes a record containing the business request and assigns it a unique correlation value.
  2. Identify the reply destination. The requester provides a reply topic and, where the design needs one, a reply partition.
  3. Process and answer. A worker consumes the request, does the work, and publishes a reply to the agreed destination while preserving the correlation value.
  4. Match the reply. The requester consumes replies and associates each with an outstanding request. It also decides when to stop waiting and what to do with a late or missing reply.

The correlation value lets the requester match a reply to a pending request; the reply destination tells the worker where to send it. Both sides need to agree on the record or header representation and reply format. These are parts of the application contract, not an automatic consequence of publishing to Kafka.

Using Spring Kafka’s request/reply support

For applications using Spring for Apache Kafka, the version 3.1.x reference documents ReplyingKafkaTemplate for a single request/reply scenario, alongside listener support for processing requests and producing replies. The documented default headers include KafkaHeaders.CORRELATION_ID, KafkaHeaders.REPLY_TOPIC, and the optional KafkaHeaders.REPLY_PARTITION. The listener infrastructure can echo correlation information and determine the reply topic. See the Spring Kafka 3.1.x sending messages reference.

Whether Spring can infer reply routing depends on the configured reply container. The reference describes inference when the container uses a single topic or a single topic-partition offset; other configurations may require the application to set reply headers. It also describes sharing a reply topic across templates when each instance listens on a different partition in the relevant single-partition configuration. These details are version-specific: check the reference for the Spring Kafka version in the application rather than assuming 3.1.x behavior applies unchanged.

Header names can be customized. That can help when the server is not a Spring application or does not use @KafkaListener, but it does not remove the need for an agreed contract. A non-Spring worker and the Spring requester must agree on the correlation header’s name and representation, as well as the reply routing information.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose a framework abstraction or define the contract yourself

Approach Best fit Decisions to make
Spring Kafka request/reply support An application already using Spring Kafka whose interaction fits the documented single request/reply use case. Confirm framework-version fit, reply-container configuration, and whether routing headers can be inferred or must be supplied.
Application-defined topic contract Participants that do not share Spring’s abstraction, or a system that needs a custom interaction contract. Agree on the correlation field, reply destination and optional partition, reply schema, and matching behavior. The cited Spring documentation supports customizable headers for interoperability; it does not establish equivalent built-in abstractions for other Kafka clients.

Whichever approach you choose, the requester still needs a clear policy for deadlines and replies that arrive after the caller has stopped waiting. The framework can help carry routing and correlation metadata; it cannot decide what those outcomes mean to your application.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Define the operational rules as part of the conversation

Correlation and reply-routing headers do not define the lifecycle of a pending request. Before relying on request/reply, specify the policies your application needs:

  • Deadline: How long will the requester wait before treating the request as timed out?
  • Late replies: If a reply arrives after that deadline, should the requester discard it, record it, or handle it another way?
  • Missing replies: What should the caller or surrounding workflow do when no reply arrives?
  • Cancellation and duplicates: Does the application support cancellation, and how should it handle repeated requests or replies?
  • Pending-request state and access: How long will the requester retain outstanding correlation values, and which participants are authorized to publish or consume the relevant records?

These are application design responsibilities. The cited Kafka protocol and Spring Kafka material does not quantify end-to-end latency, throughput, or reliability for a topic-level request/reply flow.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.