Now, we have a message broker (RabbitMQ). Before building an asynchronous API, we should learn how a Go program can talk to the message broker and send/receive the messages. While doing so, we'll create clients for production and consumption.
First, we have to create a connection to dial to the broker. If the connection is successful, a Channel needs to be created out of the connection. It has the API for performing operations on the message broker. Then, we can define a queue that messages are sent to. Finally, we publish a message to the queue.
We use an open source Go package called amqp for working with RabbitMQ.
Let's create our first program of this chapter:
- Create a directory like this for a message ...