

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: RabbitMQ
incomplete
2: Alternative Brokers
incomplete
3: Connect
incomplete
4: AMQP Protocol
incomplete
5: MQTT and STOMP
incomplete
This lesson's interactive features are locked, please to keep using them
Let's scaffold the Peril project! Fork and then clone starter code from GitHub and move it somewhere on your machine. We will use this project for the rest of the course.
The starter code contains a few interesting things
src/internal/gamelogic directory which contains the game logic modules for the Peril game.src/internal/routing/routing.ts which contains some routing constants for the game.src/client/index.ts and src/server/index.ts, which are entry point scripts that run the client and server for the game.rabbit.sh script for starting and stopping RabbitMQ with Docker. For convenience, there are wrappers around this script in package.json so that you can run:
npm run rabbit:start to start RabbitMQnpm run rabbit:stop to stop itnpm run rabbit:logs to view the server logsnpm install amqplib
import amqp from "amqplib";
async function main() {
const rabbitConnString = "amqp://guest:guest@localhost:5672/";
const conn = await amqp.connect(rabbitConnString);
...
To test your code, use the script to start a RabbitMQ server with Docker in the background:
npm run rabbit:start
Once it's running, open a new terminal and run your server:
npm run server
You should see your message that the connection was successful. Press Ctrl+C to exit the program and see the shutdown message.