Learn more
Publishing events
Property | Description | Required |
---|---|---|
topic | A broad grouping of events. | Yes |
payload | The data you want to send to the subscribers. | Yes |
channel | Dynamic grouping of events. Used to target events to specific subscribers. | No |
key | A unique identifier for a single or series of events within a topic or channel. | No |
Examples
- Send event to all subscribers
- Send event to specific subscribers
- Ordering of events
- Stateful events
- Deleting stored events
Properties
Topic
Topics are the way we group events in Exoquic. They can be anything you want, but it's a good idea to use them to group related events. For example, you might use a topic called payments
to group all events related to payments, such as payment-succeeded
or payment-failed
.
Ordering of events
The order of events when published to a topic is not guaranteed to be the same as the order at which they are received by subscribers. To preserve the order of events, you should also specify a channel in the event.
Payload
Payload is the data you want to send to the subscribers. The payload is a string of data.
Channel
Channels are like topics, but they are used to group events by a specific property. For example, you might use a channel called user-123
to group all events related to user 123. The main difference between topics and channels is that events in the same channel are ordered. A subscriber will always receive events in the same order within a channel.
Channels are commonly used to target events to a specific user. For example, if you are building a chat application, you might want to target all events related to a specific user by using their user id as the channel. That user can then subscribe to all events in that channel.
Channels are cheap
Channels are cheap compared to topics. You can have as many channels as you want.
Key
A key is a unique identification for a single or series of events within a topic/channel. The key has multiple uses:
Compaction: Compaction is a mechanism in Exoquic that reduces the amount of stored events by deleting all the events with the same key except for the latest produced event. This is useful if you have stateful events in a topic, for example, a
users
topic that stores user data. By sending an event with a key for each user, exoquic can compact the topic to only keep the latest user data. Compaction is turned on by default and can be turned on/off for a topic in your dashboard.Tombstone events: A tombstone event is an event with a key and an empty payload. When such an event is published, the events with the same key are marked for deletion. In at most a few hours, the events will be permanently deleted.
Default value
If you don't specify a key when publishing an event, a randomly generated value is used. This allows you to delete the specific event by the key.