AsyncAPI and Springwolf: Automated documentation and more

RaphaelDeLio1 16 views 43 slides Jun 26, 2024
Slide 1
Slide 1 of 49
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35
Slide 36
36
Slide 37
37
Slide 38
38
Slide 39
39
Slide 40
40
Slide 41
41
Slide 42
42
Slide 43
43
Slide 44
44
Slide 45
45
Slide 46
46
Slide 47
47
Slide 48
48
Slide 49
49

About This Presentation

AsyncAPI is an open-source initiative that provides a specification to standardize the documentation of event-driven APIs, much like the OpenAPI specification does for REST APIs.
Springwolf, on the other hand, is a practical implementation of the AsyncAPI specification, specifically tailored for Spr...


Slide Content

Raphael De Lio
AsyncAPI & Springwolf

A little bit of context

The three tier application
Presentation Layer
Application Layer
Data Layer

The thing is that…
•When we are asked to make a change in
our system, it will likely be a change related
to business
•Since this is an architecture that has high
cohesion of related technology (instead of
high cohesion of business functionality)
•Usually, these changes have to be made in
all layers of our system
Presentation Layer
Application Layer
Data Layer

Why do we organize our applications like that?
•A practically universal architecture
•Why is it universal?
Presentation Layer
Application Layer
Data Layer

Why do we organize our applications like that?
•Maybe because we are likely to
repeat something that we have seen
before
•Or maybe because of how we
traditionally organize people in
companies
Presentation Layer
Application Layer
Data Layer
Frontend Developers
Java Developers
DB Admins

Not a bad architecture. Just optimised over a set of forces that
used to group people based on familiarity

These forces have changed
•Aspiration around software development has changed
•We want to ship software much faster than ever before
•We need to make it easier to make changes in our codebase

Choosing cohesion of business functionality
•In order to do it, we also need to change how we group code
•This is forcing us to rethink the way our organisations are structured
•Which in turn is forcing us to group people by the way we break our business apart

Presentation Layer
Application Layer
Data Layer
•So instead of organizing our codebase like that…

Business Line
•We decided to start organizing them like this…
Business Line Business Line Business Line Business Line

Product Catalog
Team
•And by organizing our code like this, we can now have dedicated multidisciplinary
teams working on each slice of our application
Order
Management
Team
Payment Team Shipping Team Notification Team

•And each of these business lines has its own presentation, business logic and data
layers fully managed by their respective team
Presentation
Application
Model
Presentation
Application
Model
Presentation
Application
Model
Presentation
Application
Model
Presentation
Application
Model

•It’s up to the team to decide their architecture and technology used
Product Catalog
Team
Order
Management
Team
Payment Team Shipping Team Notification Team
I need a relational
database
I work better with a
document based database

•Now, when we require a change in business to be made, it will likely fall under one dedicated
team with full end to end responsibility of making changes to this specific business
Product Catalog
Team
Order
Management
Team
Payment Team Shipping Team Notification Team
I need a new
notification to
be sent when
an order is
made

•There’s still a problem… our communication is still coupled
Product Catalog
Team
Order
Management
Team
Payment Team Shipping Team Notification Team
Notification Team, send a
notification for me!
Okay! Will Do!

•It’s also ideal to decouple the communication between our services to a non blocking
communication
Product Catalog
Team
Order
Management
Team
Payment Team Shipping Team Notification Team
An order has been
created!
My cue!

•An event is a factual statement about something that has happened
•Other micro-services can listen to the events they are interested in and react accordingly
•The micro-services that listen to the event do not need to be reachable at the time the event
is emitted. And…
•The microservice that is emitting the event doesn’t need to know anything about the
microservices that are listening to the events… Decoupling the communications between
microservices
•The distribution of responsibility we see in our event driven interactions can mirror the
distribution of responsibility we see in our organisations trying to create more autonomous
teams
Event Driven Communication

•Our software architecture is usually driven by the way we organize our teams
•We need to release faster than ever before. This forced us to reorganize our teams and
our software architecture
•This force moved us to more decoupled teams, architecture, and communication. We
moved towards micro-services with communications driven by events
Quick Recap

•Even though the goal is that we can change our software freely, parts of our service
will still be coupled to other services
•If we break compatibility with the consumers of our events, we will force them to
change as well
•We still need to be able to clearly communicate with other teams the details and
changes of our external contracts
•And that leads us to…
However

Async API

The need for better communication led us to…
•Started in 2016 at Hitch by Fran Mendez
•Inspired by OpenAPI
•Noticed a wide community was suffering from the
same problems
•Now under the Linux Foundation
•It’s a communication contract between senders
and receivers

How does it work?

Root elements
Info server
asyncapi
componentsoperationschannel

Info
Info
version
title
externalDocs
tags
license
contact
termsOfService
description

Servers
server
pathname
host
security
variables
summary
description
protocolVersion
protocol
bindings
externalDocs
tags

Channels
channel
title
address
tags
bindings
servers
parameters
messages
description
externalDocs

Operations
operations
summary
title
bindings
tags
security
action
channel
description
traits
messages

Components
components
servers
schemas
parameters
serverVariables
securitySchemes
messages
operations
channels
correlationIds
repliesreplyAddress
externalDocs
tags
operationTraits
messageTraits
serverBindings
channelBindings
operationBindings
messageBindings

Schemas

Schemas

Messages

Reply/Request
operations
summary
title
bindings
tags
security
action
channel
description
traits
messages

AsyncAPI Studio

Springwolf

History
•Created in 2018 by Stav Shamir
•Inspired by SpringFox
•Downloaded more than a half million times
•Compatible with Spring Kafka and Spring Cloud
Stream
•Monthly releases
•Strong and open community
Stav Shamir
Timon Beck Carlos Tasada
Sam0r040

What does it do?

Automated Documentation Generation
•Automatically creates comprehensive documentation: Analyzes your Spring Boot code to
understand your asynchronous APIs.
•Scans for relevant annotations: Looks for @KafkaListener and @RabbitListener to identify
message interactions.
•Extracts key information: Gathers details about message structure, channels, operations,
and more.

AsyncAPI Compliant
•Adherence to AsyncAPI specification: Documentation follows the AsyncAPI standard for
event-driven architectures.
•Standardized structure and format: Familiar to developers experienced with OpenAPI
(Swagger) for REST APIs.
•Improved understanding: Facilitates easier comprehension and adoption of the
asynchronous API by a wider audience.

Interactive Web UI
•Web-based interface: Offers a user-friendly way to view and interact with the generated
AsyncAPI documentation.
•Easy navigation: Allows you to explore different parts of the documentation effortlessly.
•Exploration of channels, messages, and operations: Provides detailed insights into the
components of your asynchronous API.
•Enhanced understanding: Facilitates a deeper comprehension of how your asynchronous
API functions.

Message Publishing
•Publish messages from the web UI: Send messages to your asynchronous API directly
within the documentation interface.
•Simplified testing and debugging: Allows for convenient interaction with the API during
development and troubleshooting.
•Improved developer experience: Offers a streamlined workflow for testing message
interactions without writing additional code

Benefits
•Reduced Manual Effort: You don't have to write and maintain complex AsyncAPI
documentation manually. Springwolf does it for you, saving you time and effort.
•Improved Collaboration: The standardized and interactive documentation makes it easier
for different teams (development, QA, etc.) to collaborate on asynchronous API projects.
•Faster Onboarding: New developers can quickly get up to speed with your asynchronous
API by exploring the generated documentation.
•Enhanced Testing: The message publishing feature (if enabled) simplifies testing and
debugging of your asynchronous API.

How does it do it?
•Generates an AsyncAPI file automatically by scanning annotations such as
@KafkaListener, @SqsListener, and @RabbitListener
•Provides a UI allowing us to quickly see which channels our applications interact with
•Generates example payloads for our schemas
•Allows us to send messages to our broker directly from the UI

Let’s look at the code

What’s next?

Try it out!

Contribute!

Raphael De Lio
•Software Consultant @ Xebia
•Knowledge sharer:
- YouTube
- Medium
- Spring Builders
•Kotlin Dutch User Group Organizer
Tags