Kafka headers are optional key-value pairs of metadata attached to each record, next to its key and value. Use them for information about a message that should not live inside the payload.
Common uses:
Routing, where consumers route messages based on a header.
Tracing, where a correlation ID follows a request across services.
Security context, such as an authentication token.
Content metadata, such as the MIME type or encoding.
Source identification, naming the origin system.
// Producer adding headers
ProducerRecord<String, String> record = new ProducerRecord<>(
"my-topic", "key", "value");
record.headers().add("correlation-id", "12345".getBytes());
record.headers().add("source-system", "order-service".getBytes());
Headers do not affect partitioning, and they add metadata without changing the message payload.
Rewriting in plainer words…
This answer doesn't lend itself to a diagram - it reads best . No credits were charged.