podverse-mq 5.1.6-alpha.0 → 5.1.6-alpha.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/dist/functions/mq/rss/dlqHandling.d.ts +4 -0
- package/dist/functions/mq/rss/dlqHandling.d.ts.map +1 -0
- package/dist/functions/mq/rss/dlqHandling.js +72 -0
- package/dist/functions/mq/rss/runParser.d.ts.map +1 -1
- package/dist/functions/mq/rss/runParser.js +10 -4
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/services/activeMQArtemis/index.d.ts +9 -8
- package/dist/services/activeMQArtemis/index.d.ts.map +1 -1
- package/dist/services/activeMQArtemis/index.js +62 -44
- package/package.json +3 -7
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ActiveMQArtemisService } from '../../../services/activeMQArtemis';
|
|
2
|
+
export type DQLMessageLogger = (logMessage: string) => void;
|
|
3
|
+
export declare const mqRSSSetupDlqConsumers: (artemisService: ActiveMQArtemisService, logger: DQLMessageLogger) => Promise<void>;
|
|
4
|
+
//# sourceMappingURL=dlqHandling.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dlqHandling.d.ts","sourceRoot":"","sources":["../../../../src/functions/mq/rss/dlqHandling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAe,MAAM,mCAAmC,CAAC;AAGxF,MAAM,MAAM,gBAAgB,GAAG,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;AA+C5D,eAAO,MAAM,sBAAsB,GAAU,gBAAgB,sBAAsB,EAAE,QAAQ,gBAAgB,kBA0B5G,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.mqRSSSetupDlqConsumers = void 0;
|
|
13
|
+
const processDlqMessage = (context, queue, logger) => {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
15
|
+
try {
|
|
16
|
+
const bodyRaw = (_a = context.message) === null || _a === void 0 ? void 0 : _a.body;
|
|
17
|
+
const bodyStr = typeof bodyRaw === 'string' ? bodyRaw : (_c = (_b = bodyRaw === null || bodyRaw === void 0 ? void 0 : bodyRaw.toString) === null || _b === void 0 ? void 0 : _b.call(bodyRaw)) !== null && _c !== void 0 ? _c : '';
|
|
18
|
+
const appProps = ((_d = context.message) === null || _d === void 0 ? void 0 : _d.application_properties) || {};
|
|
19
|
+
const annotations = ((_e = context.message) === null || _e === void 0 ? void 0 : _e.message_annotations) || {};
|
|
20
|
+
const failureReason = appProps['_AMQ_DLQ_DELIVERY_FAILURE_CAUSE'] ||
|
|
21
|
+
appProps['x-opt-delivery-failure-cause'] ||
|
|
22
|
+
annotations['x-opt-delivery-failure-cause'] ||
|
|
23
|
+
annotations['_AMQ_DLQ_DELIVERY_FAILURE_CAUSE'] ||
|
|
24
|
+
'Unknown reason';
|
|
25
|
+
const logObject = {
|
|
26
|
+
level: 'info',
|
|
27
|
+
message: 'Processed DLQ message',
|
|
28
|
+
timestamp: new Date().toISOString(),
|
|
29
|
+
queue,
|
|
30
|
+
body: bodyStr ? safeJson(bodyStr) : null,
|
|
31
|
+
failureReason: String(failureReason),
|
|
32
|
+
appProps,
|
|
33
|
+
annotations
|
|
34
|
+
};
|
|
35
|
+
logger(JSON.stringify(logObject));
|
|
36
|
+
(_f = context.delivery) === null || _f === void 0 ? void 0 : _f.accept();
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
const errorObject = {
|
|
40
|
+
level: 'error',
|
|
41
|
+
message: 'Error processing DLQ message',
|
|
42
|
+
timestamp: new Date().toISOString(),
|
|
43
|
+
error: error.message,
|
|
44
|
+
stack: error.stack,
|
|
45
|
+
queue
|
|
46
|
+
};
|
|
47
|
+
logger(JSON.stringify(errorObject));
|
|
48
|
+
(_g = context.delivery) === null || _g === void 0 ? void 0 : _g.reject({ condition: 'dlq-processing-error', description: error.message });
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
function safeJson(s) {
|
|
52
|
+
try {
|
|
53
|
+
return JSON.parse(s);
|
|
54
|
+
}
|
|
55
|
+
catch (_a) {
|
|
56
|
+
return s;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
const mqRSSSetupDlqConsumers = (artemisService, logger) => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
const dlqQueues = ['DLQ.rss-normal', 'DLQ.rss-on-demand', 'DLQ.rss-live'];
|
|
61
|
+
for (let i = 0; i < 10; i++) {
|
|
62
|
+
yield artemisService.sendSampleToDLQ('rss-normal', { url: 'https://example.com/feed.xml', podcast_index_id: 123 }, 'Manual DLQ seed for verification');
|
|
63
|
+
yield artemisService.sendSampleToDLQ('rss-on-demand', { url: 'https://example.com/feed.xml', podcast_index_id: 123 }, 'Manual DLQ seed for verification');
|
|
64
|
+
yield artemisService.sendSampleToDLQ('rss-live', { url: 'https://example.com/feed.xml', podcast_index_id: 123 }, 'Manual DLQ seed for verification');
|
|
65
|
+
}
|
|
66
|
+
for (const q of dlqQueues) {
|
|
67
|
+
yield artemisService.consumeMessages(q, (context) => {
|
|
68
|
+
processDlqMessage(context, q, logger);
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
exports.mqRSSSetupDlqConsumers = mqRSSSetupDlqConsumers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runParser.d.ts","sourceRoot":"","sources":["../../../../src/functions/mq/rss/runParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEtF,eAAO,MAAM,cAAc,GACzB,wBAAwB,sBAAsB,EAC9C,WAAW,WAAW,
|
|
1
|
+
{"version":3,"file":"runParser.d.ts","sourceRoot":"","sources":["../../../../src/functions/mq/rss/runParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAEtF,eAAO,MAAM,cAAc,GACzB,wBAAwB,sBAAsB,EAC9C,WAAW,WAAW,kBAwBvB,CAAC"}
|
|
@@ -13,20 +13,26 @@ exports.mqRSSRunParser = void 0;
|
|
|
13
13
|
const podverse_parser_1 = require("podverse-parser");
|
|
14
14
|
const mqRSSRunParser = (activeMQArtemisService, queueName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15
15
|
yield activeMQArtemisService.initialize();
|
|
16
|
-
yield activeMQArtemisService.consumeMessages(queueName, (
|
|
16
|
+
yield activeMQArtemisService.consumeMessages(queueName, (context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
var _a, _b, _c, _d;
|
|
17
18
|
try {
|
|
18
|
-
const
|
|
19
|
-
const receivedMessage = JSON.parse(
|
|
19
|
+
const bodyStr = (_b = (_a = context.message) === null || _a === void 0 ? void 0 : _a.body) !== null && _b !== void 0 ? _b : '';
|
|
20
|
+
const receivedMessage = JSON.parse(bodyStr);
|
|
20
21
|
const { url, podcast_index_id } = receivedMessage;
|
|
21
22
|
if (url || podcast_index_id) {
|
|
22
23
|
yield (0, podverse_parser_1.parseRSSFeedAndSaveToDatabase)(url, podcast_index_id);
|
|
24
|
+
(_c = context.delivery) === null || _c === void 0 ? void 0 : _c.accept();
|
|
23
25
|
}
|
|
24
26
|
else {
|
|
25
|
-
throw new Error(`mqRSSRunParser: url or podcast_index_id not found in message ${
|
|
27
|
+
throw new Error(`mqRSSRunParser: url or podcast_index_id not found in message ${bodyStr}`);
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
catch (error) {
|
|
29
31
|
console.error('Error processing message', error);
|
|
32
|
+
(_d = context.delivery) === null || _d === void 0 ? void 0 : _d.reject({
|
|
33
|
+
condition: 'podverse:processing-error',
|
|
34
|
+
description: error.message,
|
|
35
|
+
});
|
|
30
36
|
}
|
|
31
37
|
}));
|
|
32
38
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import './module-alias-config';
|
|
|
2
2
|
export { mqRSSAdd } from './functions/mq/rss/add';
|
|
3
3
|
export { mqRSSAddAll } from './functions/mq/rss/addAll';
|
|
4
4
|
export { mqRSSAddRecentlyUpdatedFeedsFromPodcastIndex } from './functions/mq/rss/addRecentlyUpdatedFeedsFromPodcastIndex';
|
|
5
|
+
export { mqRSSSetupDlqConsumers } from './functions/mq/rss/dlqHandling';
|
|
5
6
|
export { mqRSSRunParser } from './functions/mq/rss/runParser';
|
|
6
7
|
export { mqRSSRunLiveItemListener } from './functions/mq/rss/runLiveItemListener';
|
|
7
8
|
export { ActiveMQArtemisService, ActiveMQArtemisServiceParams } from './services/activeMQArtemis';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,4CAA4C,EAAE,MAAM,4DAA4D,CAAC;AAC1H,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAElF,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,uBAAuB,CAAC;AAE/B,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,4CAA4C,EAAE,MAAM,4DAA4D,CAAC;AAC1H,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AAElF,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ActiveMQArtemisService = exports.mqRSSRunLiveItemListener = exports.mqRSSRunParser = exports.mqRSSAddRecentlyUpdatedFeedsFromPodcastIndex = exports.mqRSSAddAll = exports.mqRSSAdd = void 0;
|
|
3
|
+
exports.ActiveMQArtemisService = exports.mqRSSRunLiveItemListener = exports.mqRSSRunParser = exports.mqRSSSetupDlqConsumers = exports.mqRSSAddRecentlyUpdatedFeedsFromPodcastIndex = exports.mqRSSAddAll = exports.mqRSSAdd = void 0;
|
|
4
4
|
require("./module-alias-config");
|
|
5
5
|
var add_1 = require("./functions/mq/rss/add");
|
|
6
6
|
Object.defineProperty(exports, "mqRSSAdd", { enumerable: true, get: function () { return add_1.mqRSSAdd; } });
|
|
@@ -8,6 +8,8 @@ var addAll_1 = require("./functions/mq/rss/addAll");
|
|
|
8
8
|
Object.defineProperty(exports, "mqRSSAddAll", { enumerable: true, get: function () { return addAll_1.mqRSSAddAll; } });
|
|
9
9
|
var addRecentlyUpdatedFeedsFromPodcastIndex_1 = require("./functions/mq/rss/addRecentlyUpdatedFeedsFromPodcastIndex");
|
|
10
10
|
Object.defineProperty(exports, "mqRSSAddRecentlyUpdatedFeedsFromPodcastIndex", { enumerable: true, get: function () { return addRecentlyUpdatedFeedsFromPodcastIndex_1.mqRSSAddRecentlyUpdatedFeedsFromPodcastIndex; } });
|
|
11
|
+
var dlqHandling_1 = require("./functions/mq/rss/dlqHandling");
|
|
12
|
+
Object.defineProperty(exports, "mqRSSSetupDlqConsumers", { enumerable: true, get: function () { return dlqHandling_1.mqRSSSetupDlqConsumers; } });
|
|
11
13
|
var runParser_1 = require("./functions/mq/rss/runParser");
|
|
12
14
|
Object.defineProperty(exports, "mqRSSRunParser", { enumerable: true, get: function () { return runParser_1.mqRSSRunParser; } });
|
|
13
15
|
var runLiveItemListener_1 = require("./functions/mq/rss/runLiveItemListener");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventContext } from 'rhea';
|
|
2
2
|
import { LoggerService } from 'podverse-helpers/dist/lib/backend/logger';
|
|
3
|
-
export type MQQueueName = 'rss-normal' | 'rss-on-demand' | 'rss-live'
|
|
3
|
+
export type MQQueueName = 'rss-normal' | 'rss-on-demand' | 'rss-live' | 'DLQ' | `DLQ.${'rss-normal' | 'rss-on-demand' | 'rss-live'}`;
|
|
4
4
|
type MQRSSMessage = {
|
|
5
5
|
url: string;
|
|
6
6
|
podcast_index_id: number | null;
|
|
@@ -33,12 +33,13 @@ export declare class ActiveMQArtemisService {
|
|
|
33
33
|
private ensureReceiver;
|
|
34
34
|
private computeDuplicateId;
|
|
35
35
|
sendMessage(params: SendMessageParams): Promise<void>;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Send a sample message directly to the Dead Letter Address for the given queue.
|
|
38
|
+
* Useful for debugging DLQ consumers without needing to trigger failures.
|
|
39
|
+
* The DLQ queues are bound to addresses of the form `DLQ.<queueName>`.
|
|
40
|
+
*/
|
|
41
|
+
sendSampleToDLQ(queueName: MQQueueName, sample: Record<string, unknown>, failureDescription?: string): Promise<void>;
|
|
42
|
+
consumeMessages(queueName: MQQueueName, processMessage: (context: EventContext) => Promise<void> | void): Promise<void>;
|
|
42
43
|
}
|
|
43
44
|
export {};
|
|
44
45
|
//# 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,
|
|
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;AAIzE,MAAM,MAAM,WAAW,GACnB,YAAY,GACZ,eAAe,GACf,UAAU,GACV,KAAK,GACL,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;IAChB,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAAA;IAC3B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAA;CACjC,CAAA;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,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;gBAEf,MAAM,EAAE,4BAA4B,EAAE,MAAM,EAAE,aAAa;IAKjE,UAAU;YASF,OAAO;YAwDP,YAAY;YAaZ,cAAc;IAa5B,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;CA0B9G"}
|
|
@@ -103,7 +103,7 @@ class ActiveMQArtemisService {
|
|
|
103
103
|
return this.receivers.get(queueName);
|
|
104
104
|
if (!this.connection)
|
|
105
105
|
yield this.connect();
|
|
106
|
-
const receiver = this.connection.open_receiver({ source: { address: queueName }, credit_window:
|
|
106
|
+
const receiver = this.connection.open_receiver({ source: { address: queueName }, credit_window: 10 });
|
|
107
107
|
return new Promise((resolve) => {
|
|
108
108
|
receiver.on('receiver_open', () => {
|
|
109
109
|
this.logger.info(`Receiver ready for queue ${queueName}`);
|
|
@@ -159,36 +159,59 @@ class ActiveMQArtemisService {
|
|
|
159
159
|
}
|
|
160
160
|
});
|
|
161
161
|
}
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
/**
|
|
163
|
+
* Send a sample message directly to the Dead Letter Address for the given queue.
|
|
164
|
+
* Useful for debugging DLQ consumers without needing to trigger failures.
|
|
165
|
+
* The DLQ queues are bound to addresses of the form `DLQ.<queueName>`.
|
|
166
|
+
*/
|
|
167
|
+
sendSampleToDLQ(queueName_1, sample_1) {
|
|
168
|
+
return __awaiter(this, arguments, void 0, function* (queueName, sample, failureDescription = 'Sample DLQ message for debugging') {
|
|
164
169
|
try {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
170
|
+
if (!this.connection)
|
|
171
|
+
yield this.connect();
|
|
172
|
+
// Choose target based on what exists in your broker
|
|
173
|
+
const dlqTargets = ['DLQ', `DLQ.${queueName}`];
|
|
174
|
+
for (const dlqQueue of dlqTargets) {
|
|
175
|
+
const sender = this.connection.open_sender({ target: { address: dlqQueue } });
|
|
176
|
+
yield new Promise((resolve) => sender.once('sender_open', () => resolve()));
|
|
177
|
+
const payload = Object.assign({}, sample);
|
|
178
|
+
const bodyString = JSON.stringify(payload);
|
|
179
|
+
const delivery = sender.send({
|
|
180
|
+
body: bodyString,
|
|
181
|
+
durable: true,
|
|
182
|
+
content_type: 'application/json',
|
|
183
|
+
application_properties: {
|
|
184
|
+
_AMQ_DLQ_DELIVERY_FAILURE_CAUSE: failureDescription,
|
|
185
|
+
'x-opt-delivery-failure-cause': failureDescription
|
|
178
186
|
}
|
|
179
|
-
};
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
187
|
+
});
|
|
188
|
+
yield new Promise((resolve, reject) => {
|
|
189
|
+
const onAccepted = (context) => {
|
|
190
|
+
if (context.delivery === delivery) {
|
|
191
|
+
this.logger.info(`DLQ sample sent to ${dlqQueue}`);
|
|
192
|
+
cleanup();
|
|
193
|
+
resolve();
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
const onRejected = (context) => {
|
|
197
|
+
if (context.delivery === delivery) {
|
|
198
|
+
const err = new Error(`DLQ sample send was rejected for ${dlqQueue}`);
|
|
199
|
+
this.logger.logError('sendSampleToDLQ: rejected', err);
|
|
200
|
+
cleanup();
|
|
201
|
+
reject(err);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
const cleanup = () => {
|
|
205
|
+
sender.removeListener('accepted', onAccepted);
|
|
206
|
+
sender.removeListener('rejected', onRejected);
|
|
207
|
+
};
|
|
208
|
+
sender.on('accepted', onAccepted);
|
|
209
|
+
sender.on('rejected', onRejected);
|
|
210
|
+
});
|
|
211
|
+
}
|
|
188
212
|
}
|
|
189
213
|
catch (error) {
|
|
190
|
-
this.logger.logError('
|
|
191
|
-
return null;
|
|
214
|
+
this.logger.logError('sendSampleToDLQ: Error sending sample to DLQ', error);
|
|
192
215
|
}
|
|
193
216
|
});
|
|
194
217
|
}
|
|
@@ -196,29 +219,24 @@ class ActiveMQArtemisService {
|
|
|
196
219
|
return __awaiter(this, void 0, void 0, function* () {
|
|
197
220
|
try {
|
|
198
221
|
const receiver = yield this.ensureReceiver(queueName);
|
|
199
|
-
|
|
200
|
-
var _a
|
|
222
|
+
receiver.on('message', (context) => __awaiter(this, void 0, void 0, function* () {
|
|
223
|
+
var _a;
|
|
201
224
|
if (context.receiver !== receiver)
|
|
202
225
|
return;
|
|
203
226
|
try {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const delivery = context.delivery;
|
|
207
|
-
const buffer = Buffer.from(body);
|
|
208
|
-
yield processMessage({ content: buffer, raw: delivery, queue: queueName });
|
|
209
|
-
delivery.accept();
|
|
227
|
+
// The processing function is now responsible for accepting/rejecting.
|
|
228
|
+
yield processMessage(context);
|
|
210
229
|
}
|
|
211
230
|
catch (err) {
|
|
212
|
-
|
|
213
|
-
(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
231
|
+
const error = err;
|
|
232
|
+
this.logger.logError('Error processing message', error);
|
|
233
|
+
// If the processor throws, reject the message as a fallback.
|
|
234
|
+
(_a = context.delivery) === null || _a === void 0 ? void 0 : _a.reject({
|
|
235
|
+
condition: 'podverse:processing-error',
|
|
236
|
+
description: error.message
|
|
237
|
+
});
|
|
218
238
|
}
|
|
219
|
-
});
|
|
220
|
-
receiver.on('message', handleMessage);
|
|
221
|
-
receiver.add_credit(1); // Start consumption
|
|
239
|
+
}));
|
|
222
240
|
this.logger.info(`Consumer is set up for queue ${queueName}`);
|
|
223
241
|
}
|
|
224
242
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "podverse-mq",
|
|
3
|
-
"version": "5.1.6-alpha.
|
|
3
|
+
"version": "5.1.6-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -15,16 +15,12 @@
|
|
|
15
15
|
},
|
|
16
16
|
"author": "",
|
|
17
17
|
"license": "AGPLv3",
|
|
18
|
-
"overrides": {
|
|
19
|
-
"fast-xml-parser": "^4.1.2",
|
|
20
|
-
"xml2js": ">=0.5.0"
|
|
21
|
-
},
|
|
22
18
|
"dependencies": {
|
|
23
19
|
"module-alias": "^2.2.3",
|
|
24
|
-
"podverse-external-services": "^5.1.6-alpha.
|
|
20
|
+
"podverse-external-services": "^5.1.6-alpha.2",
|
|
25
21
|
"podverse-helpers": "^5.1.6-alpha.0",
|
|
26
22
|
"podverse-orm": "^5.1.6-alpha.0",
|
|
27
|
-
"podverse-parser": "^5.1.6-alpha.
|
|
23
|
+
"podverse-parser": "^5.1.6-alpha.1",
|
|
28
24
|
"rhea": "^2.0.6",
|
|
29
25
|
"ws": "^8.18.3"
|
|
30
26
|
},
|