message-brokers 1.3.0 → 1.3.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/README.md
CHANGED
|
@@ -91,12 +91,13 @@ const client = new MongoClient(mongoUrl, {
|
|
|
91
91
|
|
|
92
92
|
const mongoConnectionHolder = { connection: null };
|
|
93
93
|
|
|
94
|
-
client
|
|
94
|
+
client
|
|
95
|
+
.connect()
|
|
95
96
|
.then(() => {
|
|
96
97
|
console.log("✅ MongoDB connected!");
|
|
97
98
|
mongoConnectionHolder.connection = client.db(dbName);
|
|
98
99
|
})
|
|
99
|
-
.catch(error => console.error("❌ MongoDB connection failed:", error));
|
|
100
|
+
.catch((error) => console.error("❌ MongoDB connection failed:", error));
|
|
100
101
|
|
|
101
102
|
const messageBrokers = new MessageBrokers(mongoConnectionHolder);
|
|
102
103
|
```
|
|
@@ -127,4 +128,10 @@ messageBrokers.publishHarStub(har_stub);
|
|
|
127
128
|
|
|
128
129
|
// Publish raw_queue
|
|
129
130
|
messageBrokers.publishRawQueue(raw_queue);
|
|
131
|
+
|
|
132
|
+
// Publish har_stub_with_route_params
|
|
133
|
+
messageBrokers.publishHarStubWithRouteParams(har_stub_to_report_gen);
|
|
134
|
+
|
|
135
|
+
// Publish reportgen_response
|
|
136
|
+
messageBrokers.publishReportgenResponse(rg_response);
|
|
130
137
|
```
|
package/lib/configs/mqConfigs.js
CHANGED
|
@@ -15,15 +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
|
|
19
20
|
}, {
|
|
20
21
|
queueName: "har-stub-processor",
|
|
21
22
|
routingKeyList: ["har_stub_to_report_gen"],
|
|
22
|
-
priorityQueue:
|
|
23
|
+
priorityQueue: true,
|
|
24
|
+
maxPriority: 5
|
|
23
25
|
}, {
|
|
24
26
|
queueName: "report-gen-response-processor",
|
|
25
27
|
routingKeyList: ["rg_response"],
|
|
26
|
-
priorityQueue:
|
|
28
|
+
priorityQueue: true,
|
|
29
|
+
maxPriority: 5
|
|
27
30
|
}
|
|
28
31
|
// Example for priority queue.
|
|
29
32
|
// {
|
package/lib/message-brokers.js
CHANGED
|
@@ -110,8 +110,8 @@ class MessageBrokers {
|
|
|
110
110
|
* @param {Object} raw_queue
|
|
111
111
|
* @returns
|
|
112
112
|
*/
|
|
113
|
-
async publishRawQueue(raw_queue) {
|
|
114
|
-
const response = await AmqpController.publishMessage(hv_exchange, "raw_queue", raw_queue);
|
|
113
|
+
async publishRawQueue(raw_queue, priority) {
|
|
114
|
+
const response = await AmqpController.publishMessage(hv_exchange, "raw_queue", raw_queue, priority);
|
|
115
115
|
return response;
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -120,8 +120,8 @@ class MessageBrokers {
|
|
|
120
120
|
* @param {Object} har_stub_to_report_gen
|
|
121
121
|
* @returns
|
|
122
122
|
*/
|
|
123
|
-
async publishHarStubWithRouteParams(har_stub_to_report_gen) {
|
|
124
|
-
const response = await AmqpController.publishMessage(hv_exchange, "har_stub_to_report_gen", har_stub_to_report_gen);
|
|
123
|
+
async publishHarStubWithRouteParams(har_stub_to_report_gen, priority) {
|
|
124
|
+
const response = await AmqpController.publishMessage(hv_exchange, "har_stub_to_report_gen", har_stub_to_report_gen, priority);
|
|
125
125
|
return response;
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -130,8 +130,8 @@ class MessageBrokers {
|
|
|
130
130
|
* @param {Object} rg_response
|
|
131
131
|
* @returns
|
|
132
132
|
*/
|
|
133
|
-
async publishReportgenResponse(rg_response) {
|
|
134
|
-
const response = await AmqpController.publishMessage(hv_exchange, "rg_response", rg_response);
|
|
133
|
+
async publishReportgenResponse(rg_response, priority) {
|
|
134
|
+
const response = await AmqpController.publishMessage(hv_exchange, "rg_response", rg_response, priority);
|
|
135
135
|
return response;
|
|
136
136
|
}
|
|
137
137
|
async publishPendingMessageInCache() {
|
|
@@ -44,7 +44,9 @@ RabbitMQHelper.initializeAndBindQueue = async (rabbitmqChannel, exchangeName, qu
|
|
|
44
44
|
await rabbitmqChannel.assertQueue(queueName, {
|
|
45
45
|
durable: true,
|
|
46
46
|
...(priorityQueue && {
|
|
47
|
-
|
|
47
|
+
arguments: {
|
|
48
|
+
'x-max-priority': maxPriority
|
|
49
|
+
}
|
|
48
50
|
})
|
|
49
51
|
});
|
|
50
52
|
await queueLogger(`${queueName} queue created!`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "message-brokers",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.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",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"scripts": {
|
|
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
|
+
"watch": "babel ./src -d ./lib --watch & cp -r ./src/types/message-brokers.d.ts ./lib/types",
|
|
16
17
|
"prepublishOnly": "npm run build"
|
|
17
18
|
},
|
|
18
19
|
"repository": "https://code.360hvpl.com/development/message-brokers.git",
|