Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add new consumer concept doc #991

Merged
merged 14 commits into from
Oct 25, 2022
32 changes: 32 additions & 0 deletions pages/docs/concepts/consumer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Consumer
weight: 4
---

## What is a consumer?
In an Event Driven Architecture (EDA), a consumer is an application that listens for a particular event from a broker and reacts to it.

## Why do we need consumers?
Unlike traditional REST APIs, in EDA, event consumers are not expected to respond immediately on the same connection. In this architecture, a consumer is unaware of the producer or other consumers; all they know is that when a broker sends them an event, it is because they subscribed to it.

When you want events processed asynchronously in your application, the consumer plays an important role in completing that event data flow in the event channel.

```mermaid
flowchart LR
a[Producer] -- Event A --->c[(Broker)]
a -- Event B ---> c
c -- Event A ---> d[Consumer A]
c -- Event A ---> e[Consumer B]
c -- Event B ---> e[Consumer B]
c -- Event B ---> f[Consumer C]
subgraph Consumers
d
e
f
end
```
The above diagram depicts a sample flow of events from `producer` to `broker` to `consumer`. In this instance, the `producer` publishes two events _(A and B)_ and sends them to the `broker`. Then each `consumer` subscribes to receive those events.

<Remember>
<b>Subscribers</b> can also be <a href="https://www.asyncapi.com/docs/concepts/producer">producers</a>.
</Remember>