Skip to content

Instantly share code, notes, and snippets.

@didil didil/rabbit_mq_setup.js Secret
Created Jan 28, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.