@azteam/rabbitmq-async 1.0.169 → 1.0.171
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/RabbitMQAsync.js +57 -45
- package/package.json +1 -1
- package/src/RabbitMQAsync.js +9 -2
package/lib/RabbitMQAsync.js
CHANGED
|
@@ -362,104 +362,116 @@ var RabbitMQAsync = /*#__PURE__*/function () {
|
|
|
362
362
|
switch (_context6.prev = _context6.next) {
|
|
363
363
|
case 0:
|
|
364
364
|
if (!msg) {
|
|
365
|
-
_context6.next =
|
|
365
|
+
_context6.next = 54;
|
|
366
366
|
break;
|
|
367
367
|
}
|
|
368
368
|
data = JSON.parse(msg.content.toString());
|
|
369
369
|
if (!data) {
|
|
370
|
-
_context6.next =
|
|
370
|
+
_context6.next = 51;
|
|
371
371
|
break;
|
|
372
372
|
}
|
|
373
373
|
_context6.prev = 3;
|
|
374
374
|
if (!msg.fields.redelivered) {
|
|
375
|
-
_context6.next =
|
|
375
|
+
_context6.next = 22;
|
|
376
376
|
break;
|
|
377
377
|
}
|
|
378
378
|
data.retry -= 1;
|
|
379
379
|
if (!(data.retry > 0)) {
|
|
380
|
-
_context6.next =
|
|
380
|
+
_context6.next = 16;
|
|
381
381
|
break;
|
|
382
382
|
}
|
|
383
|
-
|
|
383
|
+
if (!messageQueue.worker) {
|
|
384
|
+
_context6.next = 12;
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
_context6.next = 10;
|
|
388
|
+
return messageQueue.send(queueName, _objectSpread(_objectSpread({}, data), {}, {
|
|
389
|
+
self: true
|
|
390
|
+
}));
|
|
391
|
+
case 10:
|
|
392
|
+
_context6.next = 14;
|
|
393
|
+
break;
|
|
394
|
+
case 12:
|
|
395
|
+
_context6.next = 14;
|
|
384
396
|
return messageQueue.send(queueName, data);
|
|
385
|
-
case
|
|
386
|
-
_context6.next =
|
|
397
|
+
case 14:
|
|
398
|
+
_context6.next = 18;
|
|
387
399
|
break;
|
|
388
|
-
case
|
|
389
|
-
_context6.next =
|
|
390
|
-
return messageQueue.send(
|
|
400
|
+
case 16:
|
|
401
|
+
_context6.next = 18;
|
|
402
|
+
return messageQueue.send('RETRY', {
|
|
391
403
|
queueName: queueName,
|
|
392
404
|
data: data,
|
|
393
405
|
retry_time: new Date()
|
|
394
406
|
});
|
|
395
|
-
case
|
|
396
|
-
_context6.next =
|
|
407
|
+
case 18:
|
|
408
|
+
_context6.next = 20;
|
|
397
409
|
return channel.ack(msg);
|
|
398
|
-
case
|
|
399
|
-
_context6.next =
|
|
410
|
+
case 20:
|
|
411
|
+
_context6.next = 44;
|
|
400
412
|
break;
|
|
401
|
-
case
|
|
402
|
-
_context6.prev =
|
|
403
|
-
_context6.next =
|
|
413
|
+
case 22:
|
|
414
|
+
_context6.prev = 22;
|
|
415
|
+
_context6.next = 25;
|
|
404
416
|
return cb(data);
|
|
405
|
-
case
|
|
406
|
-
_context6.next =
|
|
417
|
+
case 25:
|
|
418
|
+
_context6.next = 27;
|
|
407
419
|
return channel.ack(msg);
|
|
408
|
-
case
|
|
409
|
-
_context6.next =
|
|
420
|
+
case 27:
|
|
421
|
+
_context6.next = 44;
|
|
410
422
|
break;
|
|
411
|
-
case
|
|
412
|
-
_context6.prev =
|
|
413
|
-
_context6.t0 = _context6["catch"](
|
|
423
|
+
case 29:
|
|
424
|
+
_context6.prev = 29;
|
|
425
|
+
_context6.t0 = _context6["catch"](22);
|
|
414
426
|
errString = _context6.t0.toString();
|
|
415
427
|
if (!_lodash["default"].some(['IllegalOperationError: Channel closed'], function (el) {
|
|
416
428
|
return _lodash["default"].includes(errString, el);
|
|
417
429
|
})) {
|
|
418
|
-
_context6.next =
|
|
430
|
+
_context6.next = 36;
|
|
419
431
|
break;
|
|
420
432
|
}
|
|
421
433
|
reject(new Error(errString));
|
|
422
|
-
_context6.next =
|
|
434
|
+
_context6.next = 44;
|
|
423
435
|
break;
|
|
424
|
-
case
|
|
436
|
+
case 36:
|
|
425
437
|
if (callbackError) {
|
|
426
438
|
callbackError(prefixQueueName, _context6.t0);
|
|
427
439
|
}
|
|
428
440
|
if (!(data.retry <= 0)) {
|
|
429
|
-
_context6.next =
|
|
441
|
+
_context6.next = 42;
|
|
430
442
|
break;
|
|
431
443
|
}
|
|
432
|
-
_context6.next =
|
|
444
|
+
_context6.next = 40;
|
|
433
445
|
return channel.ack(msg);
|
|
434
|
-
case
|
|
435
|
-
_context6.next =
|
|
446
|
+
case 40:
|
|
447
|
+
_context6.next = 44;
|
|
436
448
|
break;
|
|
437
|
-
case
|
|
438
|
-
_context6.next = 39;
|
|
439
|
-
return channel.nack(msg);
|
|
440
|
-
case 39:
|
|
449
|
+
case 42:
|
|
441
450
|
_context6.next = 44;
|
|
451
|
+
return channel.nack(msg);
|
|
452
|
+
case 44:
|
|
453
|
+
_context6.next = 49;
|
|
442
454
|
break;
|
|
443
|
-
case
|
|
444
|
-
_context6.prev =
|
|
455
|
+
case 46:
|
|
456
|
+
_context6.prev = 46;
|
|
445
457
|
_context6.t1 = _context6["catch"](3);
|
|
446
458
|
reject(_context6.t1);
|
|
447
|
-
case
|
|
448
|
-
_context6.next =
|
|
459
|
+
case 49:
|
|
460
|
+
_context6.next = 52;
|
|
449
461
|
break;
|
|
450
|
-
case
|
|
462
|
+
case 51:
|
|
451
463
|
channel.ack(msg);
|
|
452
|
-
case
|
|
453
|
-
_context6.next =
|
|
464
|
+
case 52:
|
|
465
|
+
_context6.next = 55;
|
|
454
466
|
break;
|
|
455
|
-
case
|
|
467
|
+
case 54:
|
|
456
468
|
reject(new Error('msg null'));
|
|
457
|
-
case
|
|
469
|
+
case 55:
|
|
458
470
|
case "end":
|
|
459
471
|
return _context6.stop();
|
|
460
472
|
}
|
|
461
473
|
}
|
|
462
|
-
}, _callee6, null, [[3,
|
|
474
|
+
}, _callee6, null, [[3, 46], [22, 29]]);
|
|
463
475
|
}));
|
|
464
476
|
return function (_x5) {
|
|
465
477
|
return _ref.apply(this, arguments);
|
package/package.json
CHANGED
package/src/RabbitMQAsync.js
CHANGED
|
@@ -157,9 +157,16 @@ class RabbitMQAsync {
|
|
|
157
157
|
if (msg.fields.redelivered) {
|
|
158
158
|
data.retry -= 1;
|
|
159
159
|
if (data.retry > 0) {
|
|
160
|
-
|
|
160
|
+
if (messageQueue.worker) {
|
|
161
|
+
await messageQueue.send(queueName, {
|
|
162
|
+
...data,
|
|
163
|
+
self: true,
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
await messageQueue.send(queueName, data);
|
|
167
|
+
}
|
|
161
168
|
} else {
|
|
162
|
-
await messageQueue.send(
|
|
169
|
+
await messageQueue.send('RETRY', {
|
|
163
170
|
queueName,
|
|
164
171
|
data,
|
|
165
172
|
retry_time: new Date(),
|