message-brokers 1.8.0 → 1.8.2
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
|
@@ -20,6 +20,10 @@ const mqConfigs = [{
|
|
|
20
20
|
queueName: "v2.lab-data.queue",
|
|
21
21
|
routingKeyList: ["lab_api_response.amqp"],
|
|
22
22
|
priorityQueue: false
|
|
23
|
+
}, {
|
|
24
|
+
queueName: "billing.events",
|
|
25
|
+
routingKeyList: ["billing"],
|
|
26
|
+
priorityQueue: false
|
|
23
27
|
}
|
|
24
28
|
// Example for priority queue.
|
|
25
29
|
// {
|
package/lib/message-brokers.js
CHANGED
|
@@ -8,15 +8,22 @@ const {
|
|
|
8
8
|
const hv_exchange = "hv.exchange";
|
|
9
9
|
class MessageBrokers {
|
|
10
10
|
constructor(mongoConnectionHolder, applicationName) {
|
|
11
|
+
this.mongoConnectionHolder = mongoConnectionHolder;
|
|
12
|
+
this.applicationName = applicationName || "mb_app";
|
|
13
|
+
this._initialized = false;
|
|
14
|
+
}
|
|
15
|
+
async _ensureInitialized() {
|
|
16
|
+
if (this._initialized) return;
|
|
11
17
|
try {
|
|
12
|
-
setActiveApplication(applicationName
|
|
18
|
+
setActiveApplication(this.applicationName);
|
|
13
19
|
if (!mbConfigs.rabbitmqUrl) {
|
|
14
20
|
throw new Error("RABBITMQ_URL is required for message brokers initialization.");
|
|
15
21
|
}
|
|
16
|
-
package_loader(mongoConnectionHolder, true);
|
|
22
|
+
await package_loader(this.mongoConnectionHolder, true);
|
|
17
23
|
} catch (error) {
|
|
18
|
-
package_loader(mongoConnectionHolder, false);
|
|
24
|
+
await package_loader(this.mongoConnectionHolder, false);
|
|
19
25
|
}
|
|
26
|
+
this._initialized = true;
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
/**
|
|
@@ -25,6 +32,7 @@ class MessageBrokers {
|
|
|
25
32
|
* @returns
|
|
26
33
|
*/
|
|
27
34
|
async publishHar(har) {
|
|
35
|
+
await this._ensureInitialized();
|
|
28
36
|
const response = await AmqpController.publishMessage(hv_exchange, "har", har);
|
|
29
37
|
return response;
|
|
30
38
|
}
|
|
@@ -35,6 +43,7 @@ class MessageBrokers {
|
|
|
35
43
|
* @returns
|
|
36
44
|
*/
|
|
37
45
|
async publishHarMeta(har_meta) {
|
|
46
|
+
await this._ensureInitialized();
|
|
38
47
|
const response = await AmqpController.publishMessage(hv_exchange, "har_meta", har_meta);
|
|
39
48
|
return response;
|
|
40
49
|
}
|
|
@@ -45,6 +54,7 @@ class MessageBrokers {
|
|
|
45
54
|
* @returns
|
|
46
55
|
*/
|
|
47
56
|
async publishLabApiResponse(lab_api_response) {
|
|
57
|
+
await this._ensureInitialized();
|
|
48
58
|
const response = await AmqpController.publishMessage(hv_exchange, "lab_api_response", lab_api_response, 2);
|
|
49
59
|
return response;
|
|
50
60
|
}
|
|
@@ -55,6 +65,7 @@ class MessageBrokers {
|
|
|
55
65
|
* @returns
|
|
56
66
|
*/
|
|
57
67
|
async publishHarLabApiResponse(harLab_api_response) {
|
|
68
|
+
await this._ensureInitialized();
|
|
58
69
|
const response = await AmqpController.publishMessage(hv_exchange, "har.lab_api_response", harLab_api_response);
|
|
59
70
|
return response;
|
|
60
71
|
}
|
|
@@ -65,6 +76,7 @@ class MessageBrokers {
|
|
|
65
76
|
* @returns
|
|
66
77
|
*/
|
|
67
78
|
async publishPurchaseDetails(purchase_details) {
|
|
79
|
+
await this._ensureInitialized();
|
|
68
80
|
const response = await AmqpController.publishMessage(hv_exchange, "purchase_details", purchase_details);
|
|
69
81
|
return response;
|
|
70
82
|
}
|
|
@@ -75,6 +87,7 @@ class MessageBrokers {
|
|
|
75
87
|
* @returns
|
|
76
88
|
*/
|
|
77
89
|
async publishLabLocationData(lab_location_data) {
|
|
90
|
+
await this._ensureInitialized();
|
|
78
91
|
const response = await AmqpController.publishMessage(hv_exchange, "lab_location_data", lab_location_data);
|
|
79
92
|
return response;
|
|
80
93
|
}
|
|
@@ -85,6 +98,7 @@ class MessageBrokers {
|
|
|
85
98
|
* @returns
|
|
86
99
|
*/
|
|
87
100
|
async publishInputObject(input_object) {
|
|
101
|
+
await this._ensureInitialized();
|
|
88
102
|
const response = await AmqpController.publishMessage(hv_exchange, "input_object", input_object);
|
|
89
103
|
return response;
|
|
90
104
|
}
|
|
@@ -95,6 +109,7 @@ class MessageBrokers {
|
|
|
95
109
|
* @returns
|
|
96
110
|
*/
|
|
97
111
|
async publishHarStub(har_stub) {
|
|
112
|
+
await this._ensureInitialized();
|
|
98
113
|
const response = await AmqpController.publishMessage(hv_exchange, "har_stub", har_stub);
|
|
99
114
|
return response;
|
|
100
115
|
}
|
|
@@ -105,6 +120,7 @@ class MessageBrokers {
|
|
|
105
120
|
* @returns
|
|
106
121
|
*/
|
|
107
122
|
async publishTrendingData(trending_data) {
|
|
123
|
+
await this._ensureInitialized();
|
|
108
124
|
const response = await AmqpController.publishMessage(hv_exchange, "trending_data", trending_data);
|
|
109
125
|
return response;
|
|
110
126
|
}
|
|
@@ -115,6 +131,7 @@ class MessageBrokers {
|
|
|
115
131
|
* @returns
|
|
116
132
|
*/
|
|
117
133
|
async publishRawQueue(raw_queue) {
|
|
134
|
+
await this._ensureInitialized();
|
|
118
135
|
const response = await AmqpController.publishMessage(hv_exchange, "raw_queue", raw_queue);
|
|
119
136
|
return response;
|
|
120
137
|
}
|
|
@@ -125,6 +142,7 @@ class MessageBrokers {
|
|
|
125
142
|
* @returns
|
|
126
143
|
*/
|
|
127
144
|
async publishNotificationMessagesLogs(notification_messages_logs) {
|
|
145
|
+
await this._ensureInitialized();
|
|
128
146
|
const response = await AmqpController.publishMessage(hv_exchange, "notification_messages_logs", notification_messages_logs);
|
|
129
147
|
return response;
|
|
130
148
|
}
|
|
@@ -135,10 +153,23 @@ class MessageBrokers {
|
|
|
135
153
|
* @returns
|
|
136
154
|
*/
|
|
137
155
|
async publishAmqpLabApiResponse(amqp_lab_api_response) {
|
|
156
|
+
await this._ensureInitialized();
|
|
138
157
|
const response = await AmqpController.publishMessage(hv_exchange, "lab_api_response.amqp", amqp_lab_api_response);
|
|
139
158
|
return response;
|
|
140
159
|
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* This function is used publish billing events into the exchange.
|
|
163
|
+
* @param {Object} amqp_lab_api_response
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
async publishBillingEvents(billing_events) {
|
|
167
|
+
await this._ensureInitialized();
|
|
168
|
+
const response = await AmqpController.publishMessage(hv_exchange, "billing", billing_events);
|
|
169
|
+
return response;
|
|
170
|
+
}
|
|
141
171
|
async publishPendingMessageInCache() {
|
|
172
|
+
await this._ensureInitialized();
|
|
142
173
|
return await AmqpController.publishPendingMessageInCache();
|
|
143
174
|
}
|
|
144
175
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const mongoDB = require("../helpers/mongodb.helper");
|
|
2
2
|
const {
|
|
3
3
|
getActiveApplication
|
|
4
|
-
} = require("
|
|
4
|
+
} = require("../helpers/app.helper");
|
|
5
5
|
const DeadQueueService = {};
|
|
6
6
|
DeadQueueService.storeFailureMessage = async failedMessage => {
|
|
7
7
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "message-brokers",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
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",
|