From 755ac43820137a945767e02269c52552c349f496 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Thu, 21 Oct 2021 22:04:58 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=87=20RabbitMQ=20connection=20string?= =?UTF-8?q?=20changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- queue/importQueue.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/queue/importQueue.ts b/queue/importQueue.ts index b558a35..9a22c5f 100644 --- a/queue/importQueue.ts +++ b/queue/importQueue.ts @@ -1,28 +1,28 @@ import { logger } from "../utils/logger.utils"; //RabbitMQ const amqp = require("amqplib/callback_api"); -const rabbitUrl = process.env.DOCKER_RABBITMQ_HOST ? `amqp://${process.env.DOCKER_RABBITMQ_HOST}` : `amqp://localhost`; +const rabbitUrl = process.env.DOCKER_RABBITMQ_CONNECTION_STRING ? process.env.DOCKER_RABBITMQ_CONNECTION_STRING : `amqp://localhost`; export const sendToRabbitMQ = (queueName, data) => { - // connect to local rabbitmq instance + // connect to local rabbitmq instance amqp.connect(rabbitUrl, (error0, connection) => { if (error0) { throw error0; } - // create channel + // create channel connection.createChannel((error1, channel) => { if (error1) { throw error1; } const queue = queueName; - // Checks for “queueName (updateStock)” queue. If it doesn’t exist, then it creates one. + // Checks for “queueName (updateStock)” queue. If it doesn’t exist, then it creates one. channel.assertQueue(queue, { durable: false, }); channel.sendToQueue(queue, Buffer.from(data)); logger.info(`${data} sent`); }); - setTimeout(function() { + setTimeout(function () { connection.close(); // process.exit(0); }, 500);