@azteam/rabbitmq-async 1.0.140 → 1.0.141
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/package.json +3 -2
- package/src/RabbitMQAsync.js +13 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azteam/rabbitmq-async",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.141",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"engines": {
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@azteam/util": "1.0.13",
|
|
20
20
|
"amqplib": "0.8.0",
|
|
21
|
-
"fs-extra": "10.1.0"
|
|
21
|
+
"fs-extra": "10.1.0",
|
|
22
|
+
"lodash": "4.17.21"
|
|
22
23
|
}
|
|
23
24
|
}
|
package/src/RabbitMQAsync.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import amqp from 'amqplib';
|
|
2
2
|
import {timeout} from '@azteam/util';
|
|
3
|
+
import _ from 'lodash';
|
|
3
4
|
|
|
4
5
|
class RabbitMQAsync {
|
|
5
6
|
constructor(config) {
|
|
@@ -162,13 +163,19 @@ class RabbitMQAsync {
|
|
|
162
163
|
await cb(data);
|
|
163
164
|
await channel.ack(msg);
|
|
164
165
|
} catch (err) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
await channel.ack(msg);
|
|
166
|
+
const errString = err.toString();
|
|
167
|
+
|
|
168
|
+
if (_.some(['IllegalOperationError: Channel closed'], (el) => _.includes(errString, el))) {
|
|
169
|
+
reject(new Error(errString));
|
|
170
170
|
} else {
|
|
171
|
-
|
|
171
|
+
if (callbackError) {
|
|
172
|
+
callbackError(prefixQueueName, err);
|
|
173
|
+
}
|
|
174
|
+
if (data.noRetry) {
|
|
175
|
+
await channel.ack(msg);
|
|
176
|
+
} else {
|
|
177
|
+
await channel.nack(msg);
|
|
178
|
+
}
|
|
172
179
|
}
|
|
173
180
|
}
|
|
174
181
|
}
|