@azteam/rabbitmq-async 1.0.161 → 1.0.162
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 +47 -44
- package/package.json +1 -1
- package/src/RabbitMQAsync.js +3 -0
package/lib/RabbitMQAsync.js
CHANGED
|
@@ -348,17 +348,17 @@ var RabbitMQAsync = /*#__PURE__*/function () {
|
|
|
348
348
|
switch (_context6.prev = _context6.next) {
|
|
349
349
|
case 0:
|
|
350
350
|
if (!msg) {
|
|
351
|
-
_context6.next =
|
|
351
|
+
_context6.next = 51;
|
|
352
352
|
break;
|
|
353
353
|
}
|
|
354
354
|
data = JSON.parse(msg.content.toString());
|
|
355
355
|
if (!data) {
|
|
356
|
-
_context6.next =
|
|
356
|
+
_context6.next = 48;
|
|
357
357
|
break;
|
|
358
358
|
}
|
|
359
359
|
_context6.prev = 3;
|
|
360
360
|
if (!msg.fields.redelivered) {
|
|
361
|
-
_context6.next =
|
|
361
|
+
_context6.next = 19;
|
|
362
362
|
break;
|
|
363
363
|
}
|
|
364
364
|
if (!data.retry) {
|
|
@@ -366,89 +366,92 @@ var RabbitMQAsync = /*#__PURE__*/function () {
|
|
|
366
366
|
}
|
|
367
367
|
data.retry += 1;
|
|
368
368
|
if (!(data.retry < 5)) {
|
|
369
|
-
_context6.next =
|
|
369
|
+
_context6.next = 13;
|
|
370
370
|
break;
|
|
371
371
|
}
|
|
372
|
-
|
|
372
|
+
if (messageQueue.worker && !queueName.startsWith(messageQueue.serverIp)) {
|
|
373
|
+
queueName = "".concat(messageQueue.serverIp, "_").concat(queueName);
|
|
374
|
+
}
|
|
375
|
+
_context6.next = 11;
|
|
373
376
|
return messageQueue.send(queueName, data);
|
|
374
|
-
case
|
|
375
|
-
_context6.next =
|
|
377
|
+
case 11:
|
|
378
|
+
_context6.next = 15;
|
|
376
379
|
break;
|
|
377
|
-
case
|
|
378
|
-
_context6.next =
|
|
380
|
+
case 13:
|
|
381
|
+
_context6.next = 15;
|
|
379
382
|
return messageQueue.send(messageQueue.parsePrefix('RETRY'), {
|
|
380
383
|
queueName: queueName,
|
|
381
384
|
data: data,
|
|
382
385
|
retry_time: new Date()
|
|
383
386
|
});
|
|
384
|
-
case
|
|
385
|
-
_context6.next =
|
|
387
|
+
case 15:
|
|
388
|
+
_context6.next = 17;
|
|
386
389
|
return channel.ack(msg);
|
|
387
|
-
case
|
|
388
|
-
_context6.next =
|
|
390
|
+
case 17:
|
|
391
|
+
_context6.next = 41;
|
|
389
392
|
break;
|
|
390
|
-
case
|
|
391
|
-
_context6.prev =
|
|
392
|
-
_context6.next =
|
|
393
|
+
case 19:
|
|
394
|
+
_context6.prev = 19;
|
|
395
|
+
_context6.next = 22;
|
|
393
396
|
return cb(data);
|
|
394
|
-
case
|
|
395
|
-
_context6.next =
|
|
397
|
+
case 22:
|
|
398
|
+
_context6.next = 24;
|
|
396
399
|
return channel.ack(msg);
|
|
397
|
-
case
|
|
398
|
-
_context6.next =
|
|
400
|
+
case 24:
|
|
401
|
+
_context6.next = 41;
|
|
399
402
|
break;
|
|
400
|
-
case
|
|
401
|
-
_context6.prev =
|
|
402
|
-
_context6.t0 = _context6["catch"](
|
|
403
|
+
case 26:
|
|
404
|
+
_context6.prev = 26;
|
|
405
|
+
_context6.t0 = _context6["catch"](19);
|
|
403
406
|
errString = _context6.t0.toString();
|
|
404
407
|
if (!_lodash["default"].some(['IllegalOperationError: Channel closed'], function (el) {
|
|
405
408
|
return _lodash["default"].includes(errString, el);
|
|
406
409
|
})) {
|
|
407
|
-
_context6.next =
|
|
410
|
+
_context6.next = 33;
|
|
408
411
|
break;
|
|
409
412
|
}
|
|
410
413
|
reject(new Error(errString));
|
|
411
|
-
_context6.next =
|
|
414
|
+
_context6.next = 41;
|
|
412
415
|
break;
|
|
413
|
-
case
|
|
416
|
+
case 33:
|
|
414
417
|
if (callbackError) {
|
|
415
418
|
callbackError(prefixQueueName, _context6.t0);
|
|
416
419
|
}
|
|
417
420
|
if (!data.noRetry) {
|
|
418
|
-
_context6.next =
|
|
421
|
+
_context6.next = 39;
|
|
419
422
|
break;
|
|
420
423
|
}
|
|
421
|
-
_context6.next =
|
|
424
|
+
_context6.next = 37;
|
|
422
425
|
return channel.ack(msg);
|
|
423
|
-
case
|
|
424
|
-
_context6.next =
|
|
426
|
+
case 37:
|
|
427
|
+
_context6.next = 41;
|
|
425
428
|
break;
|
|
426
|
-
case
|
|
427
|
-
_context6.next =
|
|
429
|
+
case 39:
|
|
430
|
+
_context6.next = 41;
|
|
428
431
|
return channel.nack(msg);
|
|
429
|
-
case
|
|
430
|
-
_context6.next =
|
|
432
|
+
case 41:
|
|
433
|
+
_context6.next = 46;
|
|
431
434
|
break;
|
|
432
|
-
case
|
|
433
|
-
_context6.prev =
|
|
435
|
+
case 43:
|
|
436
|
+
_context6.prev = 43;
|
|
434
437
|
_context6.t1 = _context6["catch"](3);
|
|
435
438
|
reject(_context6.t1);
|
|
436
|
-
case
|
|
437
|
-
_context6.next =
|
|
439
|
+
case 46:
|
|
440
|
+
_context6.next = 49;
|
|
438
441
|
break;
|
|
439
|
-
case 47:
|
|
440
|
-
channel.ack(msg);
|
|
441
442
|
case 48:
|
|
442
|
-
|
|
443
|
+
channel.ack(msg);
|
|
444
|
+
case 49:
|
|
445
|
+
_context6.next = 52;
|
|
443
446
|
break;
|
|
444
|
-
case 50:
|
|
445
|
-
reject(new Error('msg null'));
|
|
446
447
|
case 51:
|
|
448
|
+
reject(new Error('msg null'));
|
|
449
|
+
case 52:
|
|
447
450
|
case "end":
|
|
448
451
|
return _context6.stop();
|
|
449
452
|
}
|
|
450
453
|
}
|
|
451
|
-
}, _callee6, null, [[3,
|
|
454
|
+
}, _callee6, null, [[3, 43], [19, 26]]);
|
|
452
455
|
}));
|
|
453
456
|
return function (_x5) {
|
|
454
457
|
return _ref.apply(this, arguments);
|
package/package.json
CHANGED
package/src/RabbitMQAsync.js
CHANGED
|
@@ -156,6 +156,9 @@ class RabbitMQAsync {
|
|
|
156
156
|
data.retry += 1;
|
|
157
157
|
|
|
158
158
|
if (data.retry < 5) {
|
|
159
|
+
if (messageQueue.worker && !queueName.startsWith(messageQueue.serverIp)) {
|
|
160
|
+
queueName = `${messageQueue.serverIp}_${queueName}`;
|
|
161
|
+
}
|
|
159
162
|
await messageQueue.send(queueName, data);
|
|
160
163
|
} else {
|
|
161
164
|
await messageQueue.send(messageQueue.parsePrefix('RETRY'), {
|