message-brokers 1.5.2 → 1.6.0-beta.1
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.
package/lib/configs/mqConfigs.js
CHANGED
|
@@ -15,7 +15,18 @@ const mqConfigs = [{
|
|
|
15
15
|
}, {
|
|
16
16
|
queueName: "raw-queue-processor",
|
|
17
17
|
routingKeyList: ["raw_queue"],
|
|
18
|
-
priorityQueue:
|
|
18
|
+
priorityQueue: true,
|
|
19
|
+
maxPriority: 5
|
|
20
|
+
}, {
|
|
21
|
+
queueName: "har-stub-processor",
|
|
22
|
+
routingKeyList: ["har_stub_to_report_gen"],
|
|
23
|
+
priorityQueue: true,
|
|
24
|
+
maxPriority: 5
|
|
25
|
+
}, {
|
|
26
|
+
queueName: "report-gen-response-processor",
|
|
27
|
+
routingKeyList: ["rg_response"],
|
|
28
|
+
priorityQueue: true,
|
|
29
|
+
maxPriority: 5
|
|
19
30
|
}
|
|
20
31
|
// Example for priority queue.
|
|
21
32
|
// {
|
package/lib/message-brokers.js
CHANGED
|
@@ -5,13 +5,21 @@ const mbConfigs = require("./configs/mb.configs");
|
|
|
5
5
|
const hv_exchange = "hv.exchange";
|
|
6
6
|
class MessageBrokers {
|
|
7
7
|
constructor(mongoConnectionHolder) {
|
|
8
|
+
this.mongoConnectionHolder = mongoConnectionHolder;
|
|
9
|
+
this.initialized = false;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// This function is to initialize rabbitmq
|
|
13
|
+
async init() {
|
|
8
14
|
try {
|
|
9
15
|
if (!mbConfigs.rabbitmqUrl) {
|
|
10
|
-
throw new Error("RABBITMQ_URL is
|
|
16
|
+
throw new Error("RABBITMQ_URL is reuired for message brokers initialization");
|
|
11
17
|
}
|
|
12
|
-
|
|
18
|
+
console.log(" --------------------- FROM INIT FUNCTION -----------------------------------------");
|
|
19
|
+
await package_loader(this.mongoConnectionHolder, true);
|
|
20
|
+
this.initialized = true;
|
|
13
21
|
} catch (error) {
|
|
14
|
-
package_loader(mongoConnectionHolder, false);
|
|
22
|
+
await package_loader(this.mongoConnectionHolder, false);
|
|
15
23
|
}
|
|
16
24
|
}
|
|
17
25
|
|
|
@@ -110,8 +118,28 @@ class MessageBrokers {
|
|
|
110
118
|
* @param {Object} raw_queue
|
|
111
119
|
* @returns
|
|
112
120
|
*/
|
|
113
|
-
async publishRawQueue(raw_queue) {
|
|
114
|
-
const response = await AmqpController.publishMessage(hv_exchange, "raw_queue", raw_queue);
|
|
121
|
+
async publishRawQueue(raw_queue, priority) {
|
|
122
|
+
const response = await AmqpController.publishMessage(hv_exchange, "raw_queue", raw_queue, priority);
|
|
123
|
+
return response;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* This function is used to publish request that parser sends to report_gen into the exchange.
|
|
128
|
+
* @param {Object} har_stub_to_report_gen
|
|
129
|
+
* @returns
|
|
130
|
+
*/
|
|
131
|
+
async publishHarStubWithRouteParams(har_stub_to_report_gen, priority) {
|
|
132
|
+
const response = await AmqpController.publishMessage(hv_exchange, "har_stub_to_report_gen", har_stub_to_report_gen, priority);
|
|
133
|
+
return response;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* This function is used to publish report_gen's response to parser's request into the exchange.
|
|
138
|
+
* @param {Object} rg_response
|
|
139
|
+
* @returns
|
|
140
|
+
*/
|
|
141
|
+
async publishReportgenResponse(rg_response, priority) {
|
|
142
|
+
const response = await AmqpController.publishMessage(hv_exchange, "rg_response", rg_response, priority);
|
|
115
143
|
return response;
|
|
116
144
|
}
|
|
117
145
|
|
|
@@ -29,7 +29,7 @@ RabbitMQHelper.initializePubSub = async () => {
|
|
|
29
29
|
});
|
|
30
30
|
await exchangeLogger(exchangeName);
|
|
31
31
|
for (const queueConfig of mq.queueConfigList) {
|
|
32
|
-
if (process.env.DATACLOAK_DISABLE
|
|
32
|
+
if (process.env.DATACLOAK_DISABLE && queueConfig.queueName === "datacloak.queue") {
|
|
33
33
|
console.log(`Skipping queue ${queueConfig.queueName} initialization due to DATACLOAK_DISABLE environment variable.`);
|
|
34
34
|
continue;
|
|
35
35
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "message-brokers",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0-beta.1",
|
|
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",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"install_deps": "NODE_ENV='development' yarn",
|
|
15
15
|
"build": "babel ./src -d ./lib && cp -r ./src/types/message-brokers.d.ts ./lib/types",
|
|
16
16
|
"watch": "babel ./src -d ./lib --watch & cp -r ./src/types/message-brokers.d.ts ./lib/types",
|
|
17
|
+
"watch:local": "concurrently \"npm run watch\" \"npx nodemon --watch ./lib --ext js,json --exec 'docker restart parser_dev && docker restart report_gen_dev '\"",
|
|
17
18
|
"prepublishOnly": "npm run build"
|
|
18
19
|
},
|
|
19
20
|
"repository": "https://code.360hvpl.com/development/message-brokers.git",
|