Upgrade to Pro — share decks privately, control downloads, hide ads and more …

AsyncAPI 101

AsyncAPI 101

Daniel Kocot

May 10, 2022
Tweet

More Decks by Daniel Kocot

Other Decks in Technology

Transcript

  1. Name: Daniel Kocot Role: Senior Solution Architect / Head of

    API Experience & Operations Email: Twitter: @dk_1977 LinkedIn: [email protected] https://www.linkedin.com/in/danielkocot/
  2. Protocols AMQP AMQP 1.0 HTTP IBM MQ JMS Kafka MQTT

    MQTT5 NATS Redis SNS Solace SQS STOMP WebSockets
  3. Events vs. Messages Reactive Manifesto in event-driven architecture the consumer

    decide to whom to they subscribe in message-driven architecture the consumer are known by the producer
  4. Example Info & Servers Object info: title: Order Service version:

    1.0.0 description: The service is in charge of processing orders contact: name: Daniel Kocot email: [email protected] license: name: Apache 2.0 url: https://www.apache.org/licenses/LICENSE-2.0.html servers: server: $ref: '#/components/servers/rabbitmq' channels: orderProcessed:
  5. Example Channel Object servers: - server publish: operationId: orderProcessedPub description:

    Payload of processed order message: $ref: '#/components/messages/orderProcessed' bindings: $ref: '#/components/messageBindings/amqp/bindings' subscribe: operationId: orderProcessedSub description: Payload of processed order message: $ref: '#/components/messages/orderProcessed' bindings: $ref: '#/components/messageBindings/amqp/bindings' bindings: amqp: $ref: '#/components/channelBindings/amqp' components: schemas:
  6. Example Components Object OrderPayload: type: object properties: id: type: integer

    format: int64 description: ID of received order customerReference: type: string description: Reference for the customer according the order servers: rabbitmq: url: "{stage}.codecentric.de:{port}" description: RabbitMQ Broker protocol: amqp protocolVersion: '0.9.1' variables: stage: enum: [qa, prod] default: qa port: enum: ['5672', '15672'] default: '5672' serverVariables:
  7. Kafka Operation Binding Object channels: user-signedup: publish: bindings: kafka: groupId:

    type: string enum: ['myGroupId'] clientId: type: string enum: ['myClientId'] bindingVersion: '0.1.0'
  8. Kafka Message Binding Object channels: test: publish: message: bindings: kafka:

    key: type: string enum: ['myKey'] bindingVersion: '0.1.0'
  9. MQTT Server Binding Object servers: production: bindings: mqtt: clientId: guest

    cleanSession: true lastWill: topic: /last-wills qos: 2 message: Guest gone offline. retain: false keepAlive: 60 bindingVersion: 0.1.0
  10. Message Object a message object must have payload payload can

    inline or referenced by an external file relying on the schema format provided support formats: Avro 1.9.0 schema OpenAPI 3.0.0 schema object RAML 1.0 data type Custom message parser
  11. AsyncAPI Generator api-showcases/async on  main [?] on ☁️ ➜

    ag order-service.yaml @asyncapi/html-template Done! ✨ Check out your shiny new generated files at /Users/danielkocot/api-showcases/async.
  12. AsyncAPI CLI All in one CLI for all AsyncAPI tools

    USAGE $ asyncapi [COMMAND] COMMANDS config access configs diff find diff between two asyncapi files new creates a new asyncapi file start starts a new local instance of Studio validate validate asyncapi file
  13. Modelina Generate data models for your payload npm install @asyncapi/modelina

    import { GoGenerator } from '@asyncapi/modelina'; const generator = new GoGenerator() // const input = ...AsyncAPI document const models = await generator.generate(input)
  14. Q&A