On this page


Found an error? Have a suggestion?Edit this page on Github

In the previous lesson, you learned how to create the definition of a simple Hello World application. Let's take it from there.

In this article, you'll learn how to add servers to your AsyncAPI document. Adding and defining servers is useful, because it specifies where and how to connect. The connection facilitates where to send and receive messages.

1asyncapi: 2.2.0
3  title: Hello world application
4  version: '0.1.0'
6  production:
7    url: broker.mycompany.com
8    protocol: amqp
9    description: This is "My Company" broker.
11  hello:
12    publish:
13      message:
14        payload:
15          type: string
16          pattern: '^hello .+$'

You've now added a new section called servers in your AsyncAPI document.

You might have noticed that our example mentions amqp. This protocol is very common and was popularized by RabbitMQ (among others). We picked amqp for our example, but you can use any protocol. The most common protocols used are mqtt (widely adopted by the Internet of Things and mobile apps), kafka (popular for its streaming solution), ws (WebSockets are frequently used in browsers), and http (used in HTTP streaming APIs).


The servers section defines where your application should connect to start sending and receiving messages.

  1. If you are using a broker-centric architecture such as Kafka or RabbitMQ, usually you specify the URL of the broker.
  2. If you have the classic client-server model such as for REST APIs, then your server should be the URL of the server.


Now you know where Hello world application connects to and you can start receiving hello {name} messages.

In the next chapter, you'll learn how to add security requirements to your server.

Was this helpful?
Help us improve the docs by adding your contribution.
Create Issue on Github