podverse-mq 5.1.6-alpha.4 → 5.1.6-alpha.6
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.
|
@@ -26,6 +26,7 @@ export declare class ActiveMQArtemisService {
|
|
|
26
26
|
private params;
|
|
27
27
|
private logger;
|
|
28
28
|
private connecting;
|
|
29
|
+
private isShuttingDown;
|
|
29
30
|
constructor(params: ActiveMQArtemisServiceParams, logger: LoggerService);
|
|
30
31
|
initialize(): Promise<void>;
|
|
31
32
|
private connect;
|
|
@@ -40,6 +41,8 @@ export declare class ActiveMQArtemisService {
|
|
|
40
41
|
*/
|
|
41
42
|
sendSampleToDLQ(queueName: MQQueueName, sample: Record<string, unknown>, failureDescription?: string): Promise<void>;
|
|
42
43
|
consumeMessages(queueName: MQQueueName, processMessage: (context: EventContext) => Promise<void> | void): Promise<void>;
|
|
44
|
+
getIsShuttingDown(): boolean;
|
|
45
|
+
close(): Promise<void>;
|
|
43
46
|
}
|
|
44
47
|
export {};
|
|
45
48
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/activeMQArtemis/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAgC,YAAY,EAAE,MAAM,MAAM,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,0CAA0C,CAAC;AAGzE,MAAM,MAAM,WAAW,GACnB,YAAY,GACZ,eAAe,GACf,UAAU,GACV,OAAO,YAAY,GAAG,eAAe,GAAG,UAAU,EAAE,CAAC;AAEzD,KAAK,YAAY,GAAG;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;CACjC,CAAC;AAEF,KAAK,OAAO,GAAG,YAAY,CAAC;AAE5B,KAAK,iBAAiB,GAAG;IACvB,SAAS,EAAE,WAAW,CAAA;IACtB,OAAO,EAAE,OAAO,CAAA;I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Q,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,sBAAsB;IACjC,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,OAAO,CAAuC;IACtD,OAAO,CAAC,SAAS,CAAyC;IAC1D,OAAO,CAAC,MAAM,CAA+B;IAC7C,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,cAAc,CAAS;gBAEnB,MAAM,EAAE,4BAA4B,EAAE,MAAM,EAAE,aAAa;IAKjE,UAAU;YASF,OAAO;YAwDP,YAAY;YAaZ,cAAc;IAc5B,OAAO,CAAC,kBAAkB;IAQpB,WAAW,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAyC3D;;;;OAIG;IACG,eAAe,CACnB,SAAS,EAAE,WAAW,EACtB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,kBAAkB,SAAqC,GACtD,OAAO,CAAC,IAAI,CAAC;IAoDV,eAAe,CAAC,SAAS,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IA4B7G,iBAAiB,IAAI,OAAO;IAItB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAsC7B"}
|
|
@@ -21,6 +21,7 @@ class ActiveMQArtemisService {
|
|
|
21
21
|
this.senders = new Map();
|
|
22
22
|
this.receivers = new Map();
|
|
23
23
|
this.connecting = false;
|
|
24
|
+
this.isShuttingDown = false;
|
|
24
25
|
this.params = params;
|
|
25
26
|
this.logger = logger;
|
|
26
27
|
}
|
|
@@ -103,11 +104,12 @@ class ActiveMQArtemisService {
|
|
|
103
104
|
return this.receivers.get(queueName);
|
|
104
105
|
if (!this.connection)
|
|
105
106
|
yield this.connect();
|
|
106
|
-
const receiver = this.connection.open_receiver({ source: { address: queueName }, credit_window:
|
|
107
|
+
const receiver = this.connection.open_receiver({ source: { address: queueName }, credit_window: 0 });
|
|
107
108
|
return new Promise((resolve) => {
|
|
108
109
|
receiver.on('receiver_open', () => {
|
|
109
110
|
this.logger.info(`Receiver ready for queue ${queueName}`);
|
|
110
111
|
this.receivers.set(queueName, receiver);
|
|
112
|
+
receiver.add_credit(1);
|
|
111
113
|
resolve(receiver);
|
|
112
114
|
});
|
|
113
115
|
});
|
|
@@ -236,6 +238,9 @@ class ActiveMQArtemisService {
|
|
|
236
238
|
description: error.message
|
|
237
239
|
});
|
|
238
240
|
}
|
|
241
|
+
finally {
|
|
242
|
+
receiver.add_credit(1);
|
|
243
|
+
}
|
|
239
244
|
}));
|
|
240
245
|
this.logger.info(`Consumer is set up for queue ${queueName}`);
|
|
241
246
|
}
|
|
@@ -244,5 +249,47 @@ class ActiveMQArtemisService {
|
|
|
244
249
|
}
|
|
245
250
|
});
|
|
246
251
|
}
|
|
252
|
+
getIsShuttingDown() {
|
|
253
|
+
return this.isShuttingDown;
|
|
254
|
+
}
|
|
255
|
+
close() {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
257
|
+
this.isShuttingDown = true;
|
|
258
|
+
this.logger.info('Closing ActiveMQ Artemis connection...');
|
|
259
|
+
// Close all receivers first to stop accepting new messages
|
|
260
|
+
for (const [queueName, receiver] of this.receivers.entries()) {
|
|
261
|
+
try {
|
|
262
|
+
receiver.close();
|
|
263
|
+
this.logger.info(`Closed receiver for queue ${queueName}`);
|
|
264
|
+
}
|
|
265
|
+
catch (error) {
|
|
266
|
+
this.logger.logError(`Error closing receiver for ${queueName}`, error);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
this.receivers.clear();
|
|
270
|
+
// Close all senders
|
|
271
|
+
for (const [queueName, sender] of this.senders.entries()) {
|
|
272
|
+
try {
|
|
273
|
+
sender.close();
|
|
274
|
+
this.logger.info(`Closed sender for queue ${queueName}`);
|
|
275
|
+
}
|
|
276
|
+
catch (error) {
|
|
277
|
+
this.logger.logError(`Error closing sender for ${queueName}`, error);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
this.senders.clear();
|
|
281
|
+
// Close the connection
|
|
282
|
+
if (this.connection) {
|
|
283
|
+
try {
|
|
284
|
+
this.connection.close();
|
|
285
|
+
this.logger.info('Closed ActiveMQ Artemis connection');
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
this.logger.logError('Error closing connection', error);
|
|
289
|
+
}
|
|
290
|
+
this.connection = null;
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}
|
|
247
294
|
}
|
|
248
295
|
exports.ActiveMQArtemisService = ActiveMQArtemisService;
|