From ae07c4a3342ed11bea0b595161f28318179390c5 Mon Sep 17 00:00:00 2001 From: kakabisht Date: Tue, 28 Nov 2023 18:42:02 +0530 Subject: [PATCH] intial draft for module 2 --- 100-level-AsyncAPI-Intro/step2.md | 43 +++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 100-level-AsyncAPI-Intro/step2.md diff --git a/100-level-AsyncAPI-Intro/step2.md b/100-level-AsyncAPI-Intro/step2.md new file mode 100644 index 0000000..1ebc6ac --- /dev/null +++ b/100-level-AsyncAPI-Intro/step2.md @@ -0,0 +1,43 @@ +## Event-driven architecture + +An event is a change in the system's state that triggers an action to communicate between different services. Event driven Architecture(EDA) helps break an app into multiple loosely coupled components that communicate through events. EDA is made up of event producers and consumers: + +- An event producer detects an event and transmits the event's information to the event consumers through the event channel. +- An event consumer subscribed to an event channel to receive information and process events. + +Each component can act as an event producer, consumer, or both, depending on the use case. Let us consider a coffee shop as an example: a customer(consumer) requests an espresso(event), communicating order details to the barista(producer) as a message. The following process happens, + +1. The customer orders an espresso(an event), and the order details are told to the barista(a message). +1. The barista then processes the order and starts making an espresso(a response to an event). + +So, event-driven architecture in a coffee shop is like the seamless flow of orders and drinks without everything stopping for one specific thing. It keeps things moving smoothly ☕👩‍💻 + +## Event-driven architecture with AsyncAPI + +AsyncAPI simplifies defining how to communicate and send messages between different components in an EDA. It offers a way to describe the events, channels, and message formats, making it easier to understand. + +AsyncAPI helps you define asynchronous APIs. But what is an asynchronous API? + +They are like digital mailboxes where you can send messages without waiting for an instant reply. Rather, when the other person reads your letter and has something to say, they will reply back. + +To build an EDA where certain actions(events) trigger other actions, Async API helps map out events and their response. For example, imagine a birthday party with events like cake cutting and gift opening. These events trigger responses, such as singing when the cake is cut or clapping while opening the gifts. + +AsyncAPI helps you organize events that will happen, when they will happen, and how everyone should react to them. For example, when the cake is cut, AsyncAPI guides you to sing the birthday song. It also enables creating a party schedule, like cutting the cake at 6 pm and opening gifts at 7 pm. + +Here are reasons why using AsyncAPI enhances EDA design: + +- AsyncAPI plans and describes each event and its corresponding reactions across different components. +- AsyncAPI facilitates communication between different components for seamless information exchange. +- AsyncAPI allows components to complete tasks independently without waiting. + +## Microservices with AsyncAPI + +Each microservice represents a specific function in a microservices architecture, and different microservices communicate using events. For example, one team is responsible for baking the birthday cake, and the other is responsible for decorating the room. These teams need to talk to each other to share their progress. + +AsyncAPI helps different microservices communicate with each other. For microservices to talk to each other, they would have to: + +- Define how to send and receive messages +- Schedule when to send these messages +- Ensure consistent language in messages + +AsyncAPI ensures that each microservice knows what information it will receive, how it will receive it, and what it should do with it. It also helps document interactions between microservices to help developers understand and integrate them.