Skip to content

Apache Kafka Channel Binding v0.4.0

The Apache Kafka channel binding object allows you to define Kafka-specific information for an AsyncAPI channel. This binding is essential for configuring Kafka topics, including the number of partitions, replicas, and other topic-level settings.

The Kafka channel binding provides a detailed description of a Kafka topic, enabling you to manage its configuration directly within your AsyncAPI specification. This ensures that your applications and other stakeholders have a clear and consistent understanding of the topic’s setup.

Property Type Required Description
topic string No The name of the Kafka topic. If not specified, the channel name will be used.
partitions integer No The number of partitions for the topic. Must be a positive integer.
replicas integer No The number of replicas for the topic. Must be a positive integer.
topicConfiguration object No An object containing advanced topic configuration properties.
bindingVersion string No The version of the Kafka channel binding. Defaults to latest.

The topicConfiguration object allows you to specify advanced settings for the Kafka topic.

Property Type Description
cleanup.policy array[string] The topic’s cleanup policy. Can be compact or delete. See Kafka documentation.
retention.ms integer The retention period for messages in milliseconds. See Kafka documentation.
retention.bytes integer The maximum size of the log segment. See Kafka documentation.
delete.retention.ms integer The retention period for deleted records. See Kafka documentation.
max.message.bytes integer The maximum size of a message. See Kafka documentation.

This example defines a Kafka topic with a specific number of partitions and replicas.

channels:
user-signup:
bindings:
kafka:
topic: user-signup-topic
partitions: 10
replicas: 3
bindingVersion: '0.4.0'

This example demonstrates how to set advanced topic properties, such as cleanup policy and retention settings.

channels:
order-events:
bindings:
kafka:
topic: order-events-topic
partitions: 20
replicas: 3
topicConfiguration:
cleanup.policy: ["compact", "delete"]
retention.ms: 86400000
max.message.bytes: 1048576
bindingVersion: '0.4.0'

Configure a topic with a high number of partitions to handle a large volume of incoming data from multiple producers.

channels:
iot-sensor-data:
bindings:
kafka:
topic: iot-data
partitions: 50
replicas: 3
bindingVersion: '0.4.0'

Use a compacted topic to store the full history of events for a specific entity, ensuring that only the latest state is retained.

channels:
customer-profile-events:
bindings:
kafka:
topic: customer-profiles
partitions: 5
replicas: 3
topicConfiguration:
cleanup.policy: ["compact"]
bindingVersion: '0.4.0'

Configure a topic with a specific retention period to store logs for a defined amount of time.

channels:
application-logs:
bindings:
kafka:
topic: app-logs
partitions: 10
replicas: 2
topicConfiguration:
retention.ms: 604800000 # 7 days
bindingVersion: '0.4.0'