The purpose of this document is to describe how an AsyncAPI topic should be structured. The goal is to create a definition that suites most use cases and establish the foundation for community tooling and better interoperability between products when using AsyncAPI.
A topic is a string representing where an AsyncAPI can publish or subscribe. For the sake of comparison they are like URLs in a REST API.
Below we describe the components of an AsyncAPI topic.
The name of the organization or company.
hitch
.accounts
.1
.event
.user
.signedup
The service, team or department in charge of managing the message.
hitch
.accounts
.1
.event
.user
.signedup
The version of the message for the given service. This version number should remain the same unless changes in the messages are NOT backward compatible.
hitch
.accounts
.1
.event
.user
.signedup
Note: This version number is NOT related to your service or program version.
It contains the type of the message, e.g., is it a command
or an event
?. This value should always be event
unless you're trying to explicitly execute a command in another service, i.e., when using RPC.
hitch
.accounts
.1
.event
.user
.signedup
hitch
.email
.1
.command
.user
.welcome
.send
A word (or words) describing the resource the message refers to. For instance, if you're sending a message to notify a user has just signed up, the resource should be user
. But, if you want to send a message to notify a user has just changed her full name, you could name it as user.full_name
.
hitch
.accounts
.1
.event
.user
.signedup
hitch
.email
.1
.command
.user
.welcome
.send
In case message type is event
, this should be a verb in past tense describing what happened to the resource.
In case message type is command
, this should be a verb in infinitive form describing what operation you want to perform.
hitch
.accounts
.1
.event
.user
.signedup
hitch
.email
.1
.command
.user
.welcome
.send
A word describing the status of a previous command. When used, the type of the topic MUST be event
. Allowed values are:
queued
: The command has been queued.succeeded
: The command has been handled/executed successfully.failed
: The command has failed.done
: The command has finished.
-
A user has just signed up:
hitch
.accounts
.1
.event
.user
.signedup
-
We send a welcome email:
hitch
.email
.1
.command
.user
.welcome
.send
-
But the email gets queued, so the email service sends a message to:
hitch
.email
.1
.event
.user
.welcome
.send
.queued
-
The email gets finally delivered and the email service sends messages to:
hitch
.email
.1
.event
.user
.welcome
.send
.succeeded
hitch
.email
.1
.event
.user
.welcome
.send
.done
-
Or, the recipient doesn't exist, and the email service sends messages to:
hitch
.email
.1
.event
.user
.welcome
.send
.failed
hitch
.email
.1
.event
.user
.welcome
.send
.done
-
The user sign up process has been completed so the accounts service sends:
hitch
.accounts
.1
.event
.user
.signup
.done