liveBook · Manning

AsyncAPI

As explained in Kafka for Architects

AsyncAPI is an open specification for defining and documenting asynchronous, event-driven interactions independently of a specific messaging implementation.

A team designing customer-profile and transaction topics must agree on more than topic names: partition counts, message keys, and event structures also affect how services use those topics. AsyncAPI provides a version-controlled specification for documenting these event-driven interactions. Unlike a general-purpose wiki page, its YAML or JSON files can travel with project changes in a repository. section 2.2.4 section 2.4.2

AsyncAPI describes communication through channels, messages, and operations without requiring one messaging implementation. A channel is a logical address; for Kafka, its address is a topic name. Kafka bindings add implementation-specific properties such as partition counts. section 2.2.4

Listing 2.1 An initial configuration for the Customer 360 project
asyncapi: 3.0.0
info:
  title: Customer 360 Project
  version: 1.0.0
  description: >
    This project aims to aggregate data from various sources, providing a
    comprehensive view of customer information.

channels:
  customerProfile:    #1
    description: Storing profile information of customers.
    address: CUSTOMER_PROFILES   #2
    bindings:    #3
      kafka:
        partitions: 9    #4
  transactions:
    description: Information about customer transactions.
    address: TRANSACTIONS
    bindings:
      kafka:
        partitions: 9

The Customer 360 specification gives two channels business descriptions and Kafka topic addresses, then records nine partitions for each topic. section 2.2.4

Channel documentation can also describe messages. Kafka-specific message keys belong in bindings: a customer ID keeps profile updates ordered per customer, while a transaction ID helps distribute transactions across partitions. Recording message structure gives producing and consuming teams an agreed format, even though Kafka does not enforce that structure. section 2.4.2

There are two approaches to event structure:

  • Define it in AsyncAPI for a self-contained, reusable abstract model. section 6.3.5
  • Define an Avro schema separately and reference it from AsyncAPI. This keeps the concrete schema in a developer-facing format and avoids potential translation gaps and constraint limitations in the abstract model. section 6.3.5
Listing 6.7 Referencing an Avro schema from another file
asyncapi: 3.0.0
info:
  title: Customer 360 Project
  version: 1.0.0
  description: >
    This project aims to aggregate data from various sources, providing a 
    comprehensive view of customer information.

channels:
  customerProfile:
    description: Storing and distributing profile information of customers.
    address: CUSTOMER_PROFILES 
    messages:
      userProfile:
        payload:
          schemaFormat: 'application/vnd.apache.avro;version=1.9.0'
          schema:
            $ref: './path/to/submodule/path/to/UserProfile.avsc'

The customer-profile message points to an external Avro schema, illustrating how topic documentation and a separately maintained event schema can remain connected. section 6.3.5

Use the specification as a shared record of decisions, not as a substitute for making them. Once a Kafka use case is chosen, topic requirements can include business-event references, producers, consumers, naming, replication, partitions, and retention. Keeping these definitions aligned supports consistent management of the cluster as the project grows. section 10.1.3 section 10.2

How Kafka for Architects covers it

How deep it goes
Defines channels and bindings, then compares inline event models with external schema references; stops short of a full implementation walkthrough.
Examples
Uses Customer 360 profile and transaction channels, Kafka bindings, and an external Avro schema reference.
What it assumes
Assumes basic familiarity with Kafka topics and message keys while defining AsyncAPI channels explicitly.
What you can do after
Practice/perform it: document Kafka channels and message decisions, choosing whether event structures belong inline or in referenced schemas.
How it connects
Connects Kafka topics, partitioning, message keys, Avro schemas, and event governance.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kafka for Architects. The section links point to the parts of the book it draws on.