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.
Overview
Section titled “Overview”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.
Channel Properties
Section titled “Channel Properties”| 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. |
topicConfiguration Object
Section titled “topicConfiguration Object”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. |
Examples
Section titled “Examples”Basic Topic Configuration
Section titled “Basic Topic Configuration”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'Advanced Topic Configuration
Section titled “Advanced Topic Configuration”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'Use Cases
Section titled “Use Cases”High-Throughput Data Streaming
Section titled “High-Throughput Data Streaming”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'Event Sourcing
Section titled “Event Sourcing”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'Log Aggregation
Section titled “Log Aggregation”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'