Skip to main content

Consume the event from a service

View as Markdown

In this step, you will create InventoryService and connect it to the OrderPlaced event.

In EventCatalog, a service consumes an event by listing it under receives.

In this chapter...

Here are the topics we'll cover

  • Create the InventoryService page.
  • Add OrderPlaced to the receives list.
  • Refresh EventCatalog and inspect the full relationship.

Create the service folder

From the root of your catalog, create a new folder for the service:

mkdir -p services/InventoryService

Add the service page

Create a new file at services/InventoryService/index.mdx and add receives to the frontmatter:

services/InventoryService/index.mdx
---
id: InventoryService
name: Inventory Service
version: 0.0.1
summary: |
Tracks stock levels and reserves inventory for customer orders.
receives:
- id: OrderPlaced
version: 0.0.1
---

## Overview

The inventory service tracks product avaliability and reservces stock when a customer places an order.

Keep the markdown content below the frontmatter as it is.

The frontmatter follows the same shape as OrderService:

  • id is the stable identifier EventCatalog uses for links and references.
  • name is the label people see in the UI.
  • version is the version of this service.
  • summary appears in service lists and page headers.
  • receives lists the events this service consumes.

The version field inside receives is optional. If you leave it out, EventCatalog will use the latest version of the event.

Check the service in EventCatalog

Refresh EventCatalog in your browser. You should now be able to find InventoryService in your catalog.

The Inventory Service page in EventCatalog
The Inventory Service page after adding the service file.

Check the relationship

Refresh EventCatalog in your browser and open the OrderPlaced event page.

You should now be able to see both sides of the event:

  • OrderService publishes OrderPlaced.
  • InventoryService consumes OrderPlaced.

Open the Map view from the event page to see the relationship visually.

The OrderPlaced event map showing OrderService as producer and InventoryService as consumer
The OrderPlaced map showing OrderService publishing the event and InventoryService consuming it.
Show the visualizer on the page

You can embed the same kind of visualization directly into a documentation page with the NodeGraph component:

<NodeGraph />

When used on a service or event page, NodeGraph renders the graph for the current resource.

What you have now

Your catalog now knows:

  • OrderPlaced is an event.
  • OrderPlaced has a schema.
  • OrderService publishes OrderPlaced.
  • InventoryService consumes OrderPlaced.

This is the first complete event relationship in the tutorial catalog.

Next

Continue to Add ownership.