message-brokers 1.5.2 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,7 +30,12 @@ RabbitMQHelper.initializePubSub = async () => {
30
30
  await exchangeLogger(exchangeName);
31
31
  for (const queueConfig of mq.queueConfigList) {
32
32
  if (process.env.DATACLOAK_DISABLE === "true" && queueConfig.queueName.startsWith("datacloak.queue")) {
33
- console.log(`Skipping queue ${queueConfig.queueName} initialization due to DATACLOAK_DISABLE environment variable.`);
33
+ if (RABBITMQ_DEPLOYMENT_ENV) {
34
+ queue_name = `${queueConfig.queueName}.${RABBITMQ_DEPLOYMENT_ENV}`;
35
+ }
36
+ console.log(`Skipping queue ${queue_name} initialization due to DATACLOAK_DISABLE environment variable.`);
37
+ console.log(`Deleting queue ${queue_name} if it exists.`);
38
+ await RabbitMQHelper.deleteQueue(queue_name);
34
39
  continue;
35
40
  }
36
41
  await RabbitMQHelper.initializeAndBindQueue(rabbitmqChannel, exchangeName, queueConfig);
@@ -150,4 +155,20 @@ RabbitMQHelper.publish = async (exchangeName, routingKey, message, priority = 0,
150
155
  };
151
156
  }
152
157
  };
158
+
159
+ /**
160
+ * This function is used to delete queue.
161
+ * @param {String} queueName
162
+ * @returns
163
+ */
164
+ RabbitMQHelper.deleteQueue = async queueName => {
165
+ try {
166
+ const rabbitmqChannel = await rabbitmq();
167
+ await rabbitmqChannel.deleteQueue(queueName);
168
+ console.log(`Queue ${queueName} deleted successfully`);
169
+ } catch (error) {
170
+ console.log(`Error while deleting queue ${queueName}`);
171
+ console.error(error);
172
+ }
173
+ };
153
174
  module.exports = RabbitMQHelper;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "message-brokers",
3
- "version": "1.5.2",
3
+ "version": "1.6.0",
4
4
  "description": "This package contains functions to publish the messages into the message brokers like rabbitmq.",
5
5
  "main": "lib/message-brokers.js",
6
6
  "types": "lib/types/message-brokers.d.ts",