Before diving back into the MyEvents microservice architecture, let's take a look at the basic AMQP methods that we can use. For this, we will start by building a small example program that is capable of publishing messages to an exchange.
After opening a channel, a message publisher should declare the exchange into which it intends to publish messages. For this, you can use the ExchangeDeclare() method on the channel object:
err = channel.ExchangeDeclare("events", "topic", true, false, false, false, nil) if err != nil { panic(err) }
As you can see, ExchangeDeclare takes quite a number of parameters. These are as follows:
- The exchange name
- The exchange type (remember that AMQP knows direct,