

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 9
click for more info
Not enough gems
Cost: 6 gems
1: Exchanges and Queues
incomplete
2: Types of Exchanges
incomplete
3: Create a Queue
incomplete
4: Transient Queues
incomplete
5: Decoupling
incomplete
6: Client REPL
incomplete
7: Sync vs. Async
incomplete
8: Topic Exchange
incomplete
9: Durable
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
In RabbitMQ, an exchange is where publishers send messages, typically with a routing key.
The exchange takes the message, uses the routing key as a filter, and sends the message to any queues that are listening for that routing key.
Publishers don't know about queues at all. They just send messages to exchanges, sometimes with a routing key.
Start RabbitMQ in the background with the provided script, if it isn't already running:
./rabbit.sh start
You can stop it with ./rabbit.sh stop and view the logs of the server with ./rabbit.sh logs.
Let's update our server to publish pause/resume messages to an exchange on a specific routing key. The server can then communicate with all the various players of the game to let them know when the game is paused or resumed. We'll handle the queues and consumption of the messages later.
func PublishJSON[T any](ch *amqp.Channel, exchange, key string, val T) error
go run ./cmd/server
no exchange 'peril_direct' in vhost '/'
While there are no hard errors, the message will be "unroutable" because there are no queues bound to the exchange yet, but we'll fix that later.
Run and submit the CLI tests.