7 Kafka Interaction Patterns

 

This chapter covers

  • Patterns for applying Kafka in microservices
  • Implementing a data mesh architecture with Kafka
  • Integrating data using Kafka Connect
  • An introduction to Kafka transactions

Now that you have seen some real-world use cases, let’s look at how Kafka fits into architectural patterns—so you can choose it deliberately, not by default. You’ll see where Kafka excels in microservices (smart endpoints, data mesh, CQRS, event store) and where it’s a poor match (request–response). We cover how to bring data in and out with Kafka Connect while calling out common operational pitfalls. Finally, we make Kafka’s delivery semantics concrete: durability (no data loss), exactly-once processing, and ordering—what Kafka actually guarantees and what it doesn’t. This chapter helps turn patterns into practical choices you can defend in production, backed by clear checklists and trade-offs.

7.1 Field notes: When Kafka helps—and when it hurts

The team gathers once again in the meeting room, with the whiteboard cluttered with diagrams of their Kafka setup. Max Sellington, Eva Catalyst, and Rob Routine are now deep in discussion about how Kafka fits into their architecture.

7.1 Using Kafka in Microservices

7.1.1 Smart endpoints and dumb pipes

7.1.2 Request-response pattern

7.1.3 CQRS pattern

7.1.4 Event sourcing with snapshotting

7.1.5 Having “hot” and “cold” data

7.2 Field notes: Implementing data mesh with Kafka

7.2.1 Motivations for data mesh

7.2.2 Domain ownership

7.2.3 Data as a product

7.2.4 Federated governance

7.2.5 Self-Serve platform

7.3 Using Kafka Connect

7.3.1 Kafka Connect at a glance

7.3.2 Internal Kafka Connect architecture

7.3.3 Converters

7.3.4 Single message transformations

7.3.5 Source connectors

7.3.6 Sink connectors

7.3.7 Changes in incoming data structure

7.3.8 Integrating Kafka and databases

7.3.9 Field notes: Creating connector for Customer 360

7.3.10 Common Kafka Connect problems

7.4 Ensuring delivery guarantee

7.4.1 Producer idempotence

7.4.2 Understanding Kafka transactions

7.4.3 Transactional outbox pattern

7.5 Online resources

7.6 Summary