-
-
Save didil/e8a2c62d934b6eb8f4d724c3fe3d2c0f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config(); | |
const amqp = require('amqplib'); | |
// RabbitMQ connection string | |
const messageQueueConnectionString = process.env.CLOUDAMQP_URL; | |
async function setup() { | |
console.log("Setting up RabbitMQ Exchanges/Queues"); | |
// connect to RabbitMQ Instance | |
let connection = await amqp.connect(messageQueueConnectionString); | |
// create a channel | |
let channel = await connection.createChannel(); | |
// create exchange | |
await channel.assertExchange("processing", "direct", { durable: true }); | |
// create queues | |
await channel.assertQueue("processing.requests", { durable: true }); | |
await channel.assertQueue("processing.results", { durable: true }); | |
// bind queues | |
await channel.bindQueue("processing.requests","processing", "request"); | |
await channel.bindQueue("processing.results","processing", "result"); | |
console.log("Setup DONE"); | |
process.exit(); | |
} | |
setup(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment