Skip to content

Instantly share code, notes, and snippets.

@didil
Created January 28, 2019 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save didil/e8a2c62d934b6eb8f4d724c3fe3d2c0f to your computer and use it in GitHub Desktop.
Save didil/e8a2c62d934b6eb8f4d724c3fe3d2c0f to your computer and use it in GitHub Desktop.
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