Skip to main content

Adding messages to channels

EventCatalog supports different types of messages (commands, events and queries).

Any message can be added to one or many channels.

Example

To add messages to a channel you first have to define your messages.

Once you define your message you can specify that channel/s it uses.

Adding messages to your channels​

To add a message to a channel, you need to add the channels information to your message.

Here is an example of adding channel information to an InventoryOutOfStockEvent.

/events/InventoryOutOfStockEvent/index.md (example)
---
id: InventoryOutOfStockEvent
... # other event frontmatter
channels:
# The id of the channel to map to.
- id: inventory.{env}.events
# The version of the channel, this is optional and not required
# EventCatalog will map to the latest channel version if not used.
version: 0.0.1
# optional list of params for this channel
# this example means that this message is used on the inventory.dev.events channel
parameters:
env: dev
---

<!-- Markdown contents... -->

The receives and sends fields in your service tell EventCatalog which messages this service either consumes or publishes.

Versioning your channels

Versioning for channels is optional. But if your message/channel relationship evolves over time, and you find value capturing this version/history then you can version your channels.

Using semver versioning​

You can use semver syntax when referencing your channels in your messages.

/events/InventoryOutOfStockEvent/index.md (example)
---
id: PaymentDomain
... # other domain frontmatter
channels:
# Latest minor version of InventoryEvents (channel) will be added
- id: InventoryEvents
version: 0.x.1
# Minor and patches of this version will be linked
- id: NotificationsChannel
version: ^1.0.1
# Latest version of this service will be shown by default.
- id: PaymentsChannel
---

<!-- Markdown contents... -->

Visualizing messages with channels​

When messages get added to your channels EventCatalog will visualize this for you through the visualizer.

Example