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.
How topic-level request/reply works
- Create a request. The requester publishes a record containing the business request and assigns it a unique correlation value.
- Identify the reply destination. The requester provides a reply topic and, where the design needs one, a reply partition.
- Process and answer. A worker consumes the request, does the work, and publishes a reply to the agreed destination while preserving the correlation value.
- 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.
#1 Best Overall
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.
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.
Rank #3
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.
Quick Recap
Best Value
Rank #4
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.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →




