Introduction to AsyncAPI for Kafka Lorna Mitchell, Aiven
Slide 2
Introducing: AsyncAPI Specification for describing event-driven and data streaming systems. • https://asyncapi.com • Open standard • Active community • Supports Kafka! And MQTT, AMQP, WS …. @lornajane
Slide 3
Why use AsyncAPI? Describe your event-driven systems in a useful and reusable way. • Clearly track changes in a text-based description • Generate documentation and code • Verify system operations against description • Enclose existing payload descriptions (CloudEvents, Avro) within AsyncAPI @lornajane
AsyncAPI Structure Top-level elements: • asyncapi and id • info • servers • channels • tags • components @lornajane
Slide 8
Info Section Valuable metadata is held in info. info: title: Thingum Industries Sensors description: Keeping the factory and all the machines running nicely version: 1.0.0 contact: name: Lorna email: lornajane@aiven.io url: https://github.com/aiven/thingum-industries license: name: Apache 2.0 url: http://www.apache.org/licenses/LICENSE-2.0.html
@lornajane
Slide 9
Channels Section Main operations are described here channels: door-sensor: description: Door sensors (external and internal) subscribe: operationId: DoorSensor description: Open/closed state information from the doors. tags: - name: sensor bindings: kafka: clientId: type: string message: $ref: ‘#/components/messages/DoorData’
@lornajane
Slide 10
$ref Reusable Content Refer to content in the components section message: $ref: ‘#/components/messages/DoorData’
Useful for reuse and readability. We can also refer to other files: message: $ref: ‘doors-publish.yaml#/components/messages/DoorData’
@lornajane
Slide 11
Components Section A collection of reusable components components: messages: DoorData: name: door-sensor-data title: Door Sensor Reading description: Door sensor data payload: type: object properties: location: type: string state: enum: [“open”, “closed”]
@lornajane
Slide 12
AsyncAPI Loves Standards AsyncAPI is compatible with other standards: • Avro or CloudEvent payload descriptions can be accessed with $ref • JSONSchema is supported • Based on and builds on OpenAPI
@lornajane
Slide 13
AsyncAPI Tools
Slide 14
Generate Documentation Documentation with https://www.asyncapi.com/generator
@lornajane
Slide 15
Generate Code Also using the generator: ag thingum/doors-publish.yaml \ @asyncapi/nodejs-template \ -o thingum/nodejs \ -p server=development
@lornajane