@autofleet/rabbit 2.1.1 → 2.1.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/index.js +3 -2
- package/package.json +1 -1
- package/src/index.ts +3 -2
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ const defaultOptions = {
|
|
|
46
46
|
retries: 1,
|
|
47
47
|
deadMessageTtl: DEFAULT_DEAD_TTL_TWO_DAYS,
|
|
48
48
|
};
|
|
49
|
+
const SECONDS_TO_MILLISECONDS = 1000;
|
|
49
50
|
const assertExchangeFanout = (c, exchangeName) => c.assertExchange(exchangeName, 'fanout');
|
|
50
51
|
const connectionCreatedConst = 'connectionCreated';
|
|
51
52
|
class RabbitMq {
|
|
@@ -58,7 +59,7 @@ class RabbitMq {
|
|
|
58
59
|
const { properties: { timestamp, headers } } = msg;
|
|
59
60
|
if (timestamp && (headers === null || headers === void 0 ? void 0 : headers.redisTimestampValidationKey) && this.redisClient) {
|
|
60
61
|
const lastMessageTimestamp = yield this.redisClient.getAsync(headers.redisTimestampValidationKey);
|
|
61
|
-
return !lastMessageTimestamp || !moment_1.default(parseInt(lastMessageTimestamp, 10)).isAfter(moment_1.default(timestamp));
|
|
62
|
+
return !lastMessageTimestamp || !moment_1.default(parseInt(lastMessageTimestamp, 10) * SECONDS_TO_MILLISECONDS).isAfter(moment_1.default(timestamp * SECONDS_TO_MILLISECONDS));
|
|
62
63
|
}
|
|
63
64
|
return true;
|
|
64
65
|
});
|
|
@@ -110,7 +111,7 @@ class RabbitMq {
|
|
|
110
111
|
}
|
|
111
112
|
static getPublishOptions(customHeaders = {}) {
|
|
112
113
|
return {
|
|
113
|
-
timestamp: moment_1.default().unix()
|
|
114
|
+
timestamp: moment_1.default().unix(),
|
|
114
115
|
headers: customHeaders,
|
|
115
116
|
};
|
|
116
117
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -42,6 +42,7 @@ const defaultOptions = {
|
|
|
42
42
|
retries: 1,
|
|
43
43
|
deadMessageTtl: DEFAULT_DEAD_TTL_TWO_DAYS,
|
|
44
44
|
};
|
|
45
|
+
const SECONDS_TO_MILLISECONDS = 1000;
|
|
45
46
|
|
|
46
47
|
const assertExchangeFanout = (c: any, exchangeName: string) => c.assertExchange(exchangeName, 'fanout');
|
|
47
48
|
|
|
@@ -69,7 +70,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
69
70
|
|
|
70
71
|
static getPublishOptions(customHeaders: CustomMessageHeaders = {}) {
|
|
71
72
|
return {
|
|
72
|
-
timestamp: moment().unix()
|
|
73
|
+
timestamp: moment().unix(),
|
|
73
74
|
headers: customHeaders,
|
|
74
75
|
};
|
|
75
76
|
}
|
|
@@ -110,7 +111,7 @@ class RabbitMq implements IAfRabbitMq {
|
|
|
110
111
|
const { properties: { timestamp, headers } } = msg;
|
|
111
112
|
if (timestamp && headers?.redisTimestampValidationKey && this.redisClient) {
|
|
112
113
|
const lastMessageTimestamp = await this.redisClient.getAsync(headers.redisTimestampValidationKey);
|
|
113
|
-
return !lastMessageTimestamp || !moment(parseInt(lastMessageTimestamp, 10)).isAfter(moment(timestamp));
|
|
114
|
+
return !lastMessageTimestamp || !moment(parseInt(lastMessageTimestamp, 10) * SECONDS_TO_MILLISECONDS).isAfter(moment(timestamp * SECONDS_TO_MILLISECONDS));
|
|
114
115
|
}
|
|
115
116
|
return true;
|
|
116
117
|
}
|