@azteam/rabbitmq-async 1.0.167 → 1.0.168

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.
@@ -162,6 +162,11 @@ var RabbitMQAsync = /*#__PURE__*/function () {
162
162
  }, {
163
163
  key: "parsePrefix",
164
164
  value: function parsePrefix(name) {
165
+ var self = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
166
+ if (self) {
167
+ // eslint-disable-next-line no-param-reassign
168
+ name = "".concat(this.serverIp, "_").concat(name);
169
+ }
165
170
  if (this.prefix) {
166
171
  return "".concat(this.prefix, ":").concat(name);
167
172
  }
@@ -183,7 +188,7 @@ var RabbitMQAsync = /*#__PURE__*/function () {
183
188
  case 0:
184
189
  msg = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : {};
185
190
  limit = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : 0;
186
- prefixQueueName = this.parsePrefix(queueName);
191
+ prefixQueueName = this.parsePrefix(queueName, msg.self);
187
192
  if (!this.connected) {
188
193
  _context4.next = 33;
189
194
  break;
@@ -204,7 +209,9 @@ var RabbitMQAsync = /*#__PURE__*/function () {
204
209
  break;
205
210
  }
206
211
  _context4.next = 14;
207
- return channel.sendToQueue(prefixQueueName, Buffer.from(JSON.stringify(msg)), {
212
+ return channel.sendToQueue(prefixQueueName, Buffer.from(JSON.stringify(_objectSpread({
213
+ retry: 5
214
+ }, msg))), {
208
215
  persistent: true
209
216
  });
210
217
  case 14:
@@ -250,365 +257,263 @@ var RabbitMQAsync = /*#__PURE__*/function () {
250
257
  return send;
251
258
  }()
252
259
  }, {
253
- key: "selfSend",
260
+ key: "getInfo",
254
261
  value: function () {
255
- var _selfSend = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(queueName) {
256
- var msg,
257
- limit,
262
+ var _getInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(queueName) {
263
+ var self,
264
+ prefixQueueName,
265
+ channel,
258
266
  _args5 = arguments;
259
267
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
260
268
  while (1) {
261
269
  switch (_context5.prev = _context5.next) {
262
270
  case 0:
263
- msg = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : {};
264
- limit = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : 0;
265
- this.send("".concat(this.serverIp, "_").concat(queueName), msg, limit);
266
- case 3:
267
- case "end":
268
- return _context5.stop();
269
- }
270
- }
271
- }, _callee5, this);
272
- }));
273
- function selfSend(_x2) {
274
- return _selfSend.apply(this, arguments);
275
- }
276
- return selfSend;
277
- }()
278
- }, {
279
- key: "sendNoRetry",
280
- value: function () {
281
- var _sendNoRetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(queueName) {
282
- var msg,
283
- limit,
284
- _args6 = arguments;
285
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
286
- while (1) {
287
- switch (_context6.prev = _context6.next) {
288
- case 0:
289
- msg = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
290
- limit = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : 0;
291
- this.send(queueName, _objectSpread(_objectSpread({}, msg), {}, {
292
- noRetry: true
293
- }), limit);
294
- case 3:
295
- case "end":
296
- return _context6.stop();
297
- }
298
- }
299
- }, _callee6, this);
300
- }));
301
- function sendNoRetry(_x3) {
302
- return _sendNoRetry.apply(this, arguments);
303
- }
304
- return sendNoRetry;
305
- }()
306
- }, {
307
- key: "selfSendNoRetry",
308
- value: function () {
309
- var _selfSendNoRetry = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(queueName) {
310
- var msg,
311
- limit,
312
- _args7 = arguments;
313
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
314
- while (1) {
315
- switch (_context7.prev = _context7.next) {
316
- case 0:
317
- msg = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
318
- limit = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : 0;
319
- this.selfSend(queueName, _objectSpread(_objectSpread({}, msg), {}, {
320
- noRetry: true
321
- }), limit);
322
- case 3:
323
- case "end":
324
- return _context7.stop();
325
- }
326
- }
327
- }, _callee7, this);
328
- }));
329
- function selfSendNoRetry(_x4) {
330
- return _selfSendNoRetry.apply(this, arguments);
331
- }
332
- return selfSendNoRetry;
333
- }()
334
- }, {
335
- key: "getInfo",
336
- value: function () {
337
- var _getInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(queueName) {
338
- var prefixQueueName, channel;
339
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
340
- while (1) {
341
- switch (_context8.prev = _context8.next) {
342
- case 0:
343
- prefixQueueName = this.parsePrefix(queueName);
271
+ self = _args5.length > 1 && _args5[1] !== undefined ? _args5[1] : false;
272
+ prefixQueueName = this.parsePrefix(queueName, self);
344
273
  if (!this.connected) {
345
- _context8.next = 25;
274
+ _context5.next = 26;
346
275
  break;
347
276
  }
348
- _context8.prev = 2;
349
- _context8.next = 5;
277
+ _context5.prev = 3;
278
+ _context5.next = 6;
350
279
  return this.client.createChannel();
351
- case 5:
352
- channel = _context8.sent;
353
- _context8.next = 8;
280
+ case 6:
281
+ channel = _context5.sent;
282
+ _context5.next = 9;
354
283
  return channel.assertQueue(prefixQueueName, {
355
284
  durable: true
356
285
  });
357
- case 8:
358
- return _context8.abrupt("return", _context8.sent);
359
- case 11:
360
- _context8.prev = 11;
361
- _context8.t0 = _context8["catch"](2);
362
- return _context8.abrupt("return", this.getInfo(queueName));
363
- case 14:
364
- _context8.prev = 14;
365
- _context8.prev = 15;
366
- _context8.next = 18;
286
+ case 9:
287
+ return _context5.abrupt("return", _context5.sent);
288
+ case 12:
289
+ _context5.prev = 12;
290
+ _context5.t0 = _context5["catch"](3);
291
+ return _context5.abrupt("return", this.getInfo(queueName));
292
+ case 15:
293
+ _context5.prev = 15;
294
+ _context5.prev = 16;
295
+ _context5.next = 19;
367
296
  return channel.close();
368
- case 18:
369
- _context8.next = 22;
297
+ case 19:
298
+ _context5.next = 23;
370
299
  break;
371
- case 20:
372
- _context8.prev = 20;
373
- _context8.t1 = _context8["catch"](15);
374
- case 22:
375
- return _context8.finish(14);
300
+ case 21:
301
+ _context5.prev = 21;
302
+ _context5.t1 = _context5["catch"](16);
376
303
  case 23:
377
- _context8.next = 26;
304
+ return _context5.finish(15);
305
+ case 24:
306
+ _context5.next = 27;
378
307
  break;
379
- case 25:
380
- return _context8.abrupt("return", this.getInfo(queueName));
381
308
  case 26:
309
+ return _context5.abrupt("return", this.getInfo(queueName));
310
+ case 27:
382
311
  case "end":
383
- return _context8.stop();
312
+ return _context5.stop();
384
313
  }
385
314
  }
386
- }, _callee8, this, [[2, 11, 14, 23], [15, 20]]);
315
+ }, _callee5, this, [[3, 12, 15, 24], [16, 21]]);
387
316
  }));
388
- function getInfo(_x5) {
317
+ function getInfo(_x2) {
389
318
  return _getInfo.apply(this, arguments);
390
319
  }
391
320
  return getInfo;
392
321
  }()
393
- }, {
394
- key: "getSelfInfo",
395
- value: function () {
396
- var _getSelfInfo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(queueName) {
397
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
398
- while (1) {
399
- switch (_context9.prev = _context9.next) {
400
- case 0:
401
- return _context9.abrupt("return", this.getInfo("".concat(this.serverIp, "_").concat(queueName)));
402
- case 1:
403
- case "end":
404
- return _context9.stop();
405
- }
406
- }
407
- }, _callee9, this);
408
- }));
409
- function getSelfInfo(_x6) {
410
- return _getSelfInfo.apply(this, arguments);
411
- }
412
- return getSelfInfo;
413
- }()
414
322
  }, {
415
323
  key: "consume",
416
324
  value: function () {
417
- var _consume = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(queueName, cb) {
325
+ var _consume = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(queueName, cb) {
418
326
  var callbackError,
419
327
  prefixQueueName,
420
328
  channel,
421
329
  messageQueue,
422
- _args11 = arguments;
423
- return _regeneratorRuntime().wrap(function _callee11$(_context11) {
330
+ _args7 = arguments;
331
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
424
332
  while (1) {
425
- switch (_context11.prev = _context11.next) {
333
+ switch (_context7.prev = _context7.next) {
426
334
  case 0:
427
- callbackError = _args11.length > 2 && _args11[2] !== undefined ? _args11[2] : null;
335
+ callbackError = _args7.length > 2 && _args7[2] !== undefined ? _args7[2] : null;
428
336
  prefixQueueName = this.parsePrefix(queueName);
429
337
  if (!this.connected) {
430
- _context11.next = 30;
338
+ _context7.next = 30;
431
339
  break;
432
340
  }
433
- _context11.prev = 3;
434
- _context11.next = 6;
341
+ _context7.prev = 3;
342
+ _context7.next = 6;
435
343
  return this.client.createChannel();
436
344
  case 6:
437
- channel = _context11.sent;
438
- _context11.next = 9;
345
+ channel = _context7.sent;
346
+ _context7.next = 9;
439
347
  return channel.assertQueue(prefixQueueName, {
440
348
  durable: true
441
349
  });
442
350
  case 9:
443
- _context11.next = 11;
351
+ _context7.next = 11;
444
352
  return channel.prefetch(1);
445
353
  case 11:
446
354
  messageQueue = this;
447
- _context11.next = 14;
355
+ _context7.next = 14;
448
356
  return new Promise(function (resolve, reject) {
449
357
  channel.consume(prefixQueueName, /*#__PURE__*/function () {
450
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(msg) {
358
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(msg) {
451
359
  var data, errString;
452
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
360
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
453
361
  while (1) {
454
- switch (_context10.prev = _context10.next) {
362
+ switch (_context6.prev = _context6.next) {
455
363
  case 0:
456
364
  if (!msg) {
457
- _context10.next = 55;
365
+ _context6.next = 54;
458
366
  break;
459
367
  }
460
368
  data = JSON.parse(msg.content.toString());
461
369
  if (!data) {
462
- _context10.next = 52;
370
+ _context6.next = 51;
463
371
  break;
464
372
  }
465
- _context10.prev = 3;
373
+ _context6.prev = 3;
466
374
  if (!msg.fields.redelivered) {
467
- _context10.next = 23;
375
+ _context6.next = 22;
468
376
  break;
469
377
  }
470
- if (!data.retry) {
471
- data.retry = 0;
472
- }
473
- data.retry += 1;
474
- if (!(data.retry < 5)) {
475
- _context10.next = 17;
378
+ data.retry -= 1;
379
+ if (!(data.retry > 0)) {
380
+ _context6.next = 16;
476
381
  break;
477
382
  }
478
383
  if (!(messageQueue.worker && !queueName.startsWith(messageQueue.serverIp))) {
479
- _context10.next = 13;
384
+ _context6.next = 12;
480
385
  break;
481
386
  }
482
- _context10.next = 11;
387
+ _context6.next = 10;
483
388
  return messageQueue.send("".concat(messageQueue.serverIp, "_").concat(queueName), data);
484
- case 11:
485
- _context10.next = 15;
389
+ case 10:
390
+ _context6.next = 14;
486
391
  break;
487
- case 13:
488
- _context10.next = 15;
392
+ case 12:
393
+ _context6.next = 14;
489
394
  return messageQueue.send(queueName, data);
490
- case 15:
491
- _context10.next = 19;
395
+ case 14:
396
+ _context6.next = 18;
492
397
  break;
493
- case 17:
494
- _context10.next = 19;
398
+ case 16:
399
+ _context6.next = 18;
495
400
  return messageQueue.send(messageQueue.parsePrefix('RETRY'), {
496
401
  queueName: queueName,
497
402
  data: data,
498
403
  retry_time: new Date()
499
404
  });
500
- case 19:
501
- _context10.next = 21;
405
+ case 18:
406
+ _context6.next = 20;
502
407
  return channel.ack(msg);
503
- case 21:
504
- _context10.next = 45;
408
+ case 20:
409
+ _context6.next = 44;
505
410
  break;
506
- case 23:
507
- _context10.prev = 23;
508
- _context10.next = 26;
411
+ case 22:
412
+ _context6.prev = 22;
413
+ _context6.next = 25;
509
414
  return cb(data);
510
- case 26:
511
- _context10.next = 28;
415
+ case 25:
416
+ _context6.next = 27;
512
417
  return channel.ack(msg);
513
- case 28:
514
- _context10.next = 45;
418
+ case 27:
419
+ _context6.next = 44;
515
420
  break;
516
- case 30:
517
- _context10.prev = 30;
518
- _context10.t0 = _context10["catch"](23);
519
- errString = _context10.t0.toString();
421
+ case 29:
422
+ _context6.prev = 29;
423
+ _context6.t0 = _context6["catch"](22);
424
+ errString = _context6.t0.toString();
520
425
  if (!_lodash["default"].some(['IllegalOperationError: Channel closed'], function (el) {
521
426
  return _lodash["default"].includes(errString, el);
522
427
  })) {
523
- _context10.next = 37;
428
+ _context6.next = 36;
524
429
  break;
525
430
  }
526
431
  reject(new Error(errString));
527
- _context10.next = 45;
432
+ _context6.next = 44;
528
433
  break;
529
- case 37:
434
+ case 36:
530
435
  if (callbackError) {
531
- callbackError(prefixQueueName, _context10.t0);
436
+ callbackError(prefixQueueName, _context6.t0);
532
437
  }
533
- if (!data.noRetry) {
534
- _context10.next = 43;
438
+ if (!(data.retry <= 0)) {
439
+ _context6.next = 42;
535
440
  break;
536
441
  }
537
- _context10.next = 41;
442
+ _context6.next = 40;
538
443
  return channel.ack(msg);
539
- case 41:
540
- _context10.next = 45;
444
+ case 40:
445
+ _context6.next = 44;
541
446
  break;
542
- case 43:
543
- _context10.next = 45;
447
+ case 42:
448
+ _context6.next = 44;
544
449
  return channel.nack(msg);
545
- case 45:
546
- _context10.next = 50;
450
+ case 44:
451
+ _context6.next = 49;
547
452
  break;
548
- case 47:
549
- _context10.prev = 47;
550
- _context10.t1 = _context10["catch"](3);
551
- reject(_context10.t1);
552
- case 50:
553
- _context10.next = 53;
453
+ case 46:
454
+ _context6.prev = 46;
455
+ _context6.t1 = _context6["catch"](3);
456
+ reject(_context6.t1);
457
+ case 49:
458
+ _context6.next = 52;
554
459
  break;
555
- case 52:
460
+ case 51:
556
461
  channel.ack(msg);
557
- case 53:
558
- _context10.next = 56;
462
+ case 52:
463
+ _context6.next = 55;
559
464
  break;
560
- case 55:
465
+ case 54:
561
466
  reject(new Error('msg null'));
562
- case 56:
467
+ case 55:
563
468
  case "end":
564
- return _context10.stop();
469
+ return _context6.stop();
565
470
  }
566
471
  }
567
- }, _callee10, null, [[3, 47], [23, 30]]);
472
+ }, _callee6, null, [[3, 46], [22, 29]]);
568
473
  }));
569
- return function (_x9) {
474
+ return function (_x5) {
570
475
  return _ref.apply(this, arguments);
571
476
  };
572
477
  }());
573
478
  });
574
479
  case 14:
575
- _context11.next = 28;
480
+ _context7.next = 28;
576
481
  break;
577
482
  case 16:
578
- _context11.prev = 16;
579
- _context11.t0 = _context11["catch"](3);
580
- _context11.prev = 18;
581
- _context11.next = 21;
483
+ _context7.prev = 16;
484
+ _context7.t0 = _context7["catch"](3);
485
+ _context7.prev = 18;
486
+ _context7.next = 21;
582
487
  return channel.close();
583
488
  case 21:
584
- _context11.next = 25;
489
+ _context7.next = 25;
585
490
  break;
586
491
  case 23:
587
- _context11.prev = 23;
588
- _context11.t1 = _context11["catch"](18);
492
+ _context7.prev = 23;
493
+ _context7.t1 = _context7["catch"](18);
589
494
  case 25:
590
- _context11.next = 27;
495
+ _context7.next = 27;
591
496
  return (0, _util.timeout)(5000);
592
497
  case 27:
593
- return _context11.abrupt("return", this.consume(queueName, cb, callbackError));
498
+ return _context7.abrupt("return", this.consume(queueName, cb, callbackError));
594
499
  case 28:
595
- _context11.next = 33;
500
+ _context7.next = 33;
596
501
  break;
597
502
  case 30:
598
- _context11.next = 32;
503
+ _context7.next = 32;
599
504
  return (0, _util.timeout)(5000);
600
505
  case 32:
601
- return _context11.abrupt("return", this.consume(queueName, cb, callbackError));
506
+ return _context7.abrupt("return", this.consume(queueName, cb, callbackError));
602
507
  case 33:
603
- return _context11.abrupt("return", true);
508
+ return _context7.abrupt("return", true);
604
509
  case 34:
605
510
  case "end":
606
- return _context11.stop();
511
+ return _context7.stop();
607
512
  }
608
513
  }
609
- }, _callee11, this, [[3, 16], [18, 23]]);
514
+ }, _callee7, this, [[3, 16], [18, 23]]);
610
515
  }));
611
- function consume(_x7, _x8) {
516
+ function consume(_x3, _x4) {
612
517
  return _consume.apply(this, arguments);
613
518
  }
614
519
  return consume;
@@ -616,20 +521,20 @@ var RabbitMQAsync = /*#__PURE__*/function () {
616
521
  }, {
617
522
  key: "selfReceiving",
618
523
  value: function () {
619
- var _selfReceiving = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(queueName, cb, callbackError) {
620
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
524
+ var _selfReceiving = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(queueName, cb, callbackError) {
525
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
621
526
  while (1) {
622
- switch (_context12.prev = _context12.next) {
527
+ switch (_context8.prev = _context8.next) {
623
528
  case 0:
624
529
  this.consume("".concat(this.serverIp, "_").concat(queueName), cb, callbackError);
625
530
  case 1:
626
531
  case "end":
627
- return _context12.stop();
532
+ return _context8.stop();
628
533
  }
629
534
  }
630
- }, _callee12, this);
535
+ }, _callee8, this);
631
536
  }));
632
- function selfReceiving(_x10, _x11, _x12) {
537
+ function selfReceiving(_x6, _x7, _x8) {
633
538
  return _selfReceiving.apply(this, arguments);
634
539
  }
635
540
  return selfReceiving;
@@ -637,26 +542,26 @@ var RabbitMQAsync = /*#__PURE__*/function () {
637
542
  }, {
638
543
  key: "receiving",
639
544
  value: function () {
640
- var _receiving = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(queueName, cb) {
545
+ var _receiving = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(queueName, cb) {
641
546
  var callbackError,
642
- _args13 = arguments;
643
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
547
+ _args9 = arguments;
548
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
644
549
  while (1) {
645
- switch (_context13.prev = _context13.next) {
550
+ switch (_context9.prev = _context9.next) {
646
551
  case 0:
647
- callbackError = _args13.length > 2 && _args13[2] !== undefined ? _args13[2] : null;
552
+ callbackError = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : null;
648
553
  this.consume(queueName, cb, callbackError);
649
554
  if (this.worker) {
650
555
  this.selfReceiving(queueName, cb, callbackError);
651
556
  }
652
557
  case 3:
653
558
  case "end":
654
- return _context13.stop();
559
+ return _context9.stop();
655
560
  }
656
561
  }
657
- }, _callee13, this);
562
+ }, _callee9, this);
658
563
  }));
659
- function receiving(_x13, _x14) {
564
+ function receiving(_x9, _x10) {
660
565
  return _receiving.apply(this, arguments);
661
566
  }
662
567
  return receiving;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/rabbitmq-async",
3
- "version": "1.0.167",
3
+ "version": "1.0.168",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "toda",
@@ -65,7 +65,12 @@ class RabbitMQAsync {
65
65
  this.client.close();
66
66
  }
67
67
 
68
- parsePrefix(name) {
68
+ parsePrefix(name, self = false) {
69
+ if (self) {
70
+ // eslint-disable-next-line no-param-reassign
71
+ name = `${this.serverIp}_${name}`;
72
+ }
73
+
69
74
  if (this.prefix) {
70
75
  return `${this.prefix}:${name}`;
71
76
  }
@@ -73,7 +78,7 @@ class RabbitMQAsync {
73
78
  }
74
79
 
75
80
  async send(queueName, msg = {}, limit = 0) {
76
- const prefixQueueName = this.parsePrefix(queueName);
81
+ const prefixQueueName = this.parsePrefix(queueName, msg.self);
77
82
 
78
83
  if (this.connected) {
79
84
  let channel;
@@ -84,7 +89,7 @@ class RabbitMQAsync {
84
89
  });
85
90
 
86
91
  if (limit === 0 || queueInfo.messageCount < limit) {
87
- await channel.sendToQueue(prefixQueueName, Buffer.from(JSON.stringify(msg)), {
92
+ await channel.sendToQueue(prefixQueueName, Buffer.from(JSON.stringify({retry: 5, ...msg})), {
88
93
  persistent: true,
89
94
  });
90
95
  }
@@ -104,20 +109,8 @@ class RabbitMQAsync {
104
109
  }
105
110
  }
106
111
 
107
- async selfSend(queueName, msg = {}, limit = 0) {
108
- this.send(`${this.serverIp}_${queueName}`, msg, limit);
109
- }
110
-
111
- async sendNoRetry(queueName, msg = {}, limit = 0) {
112
- this.send(queueName, {...msg, noRetry: true}, limit);
113
- }
114
-
115
- async selfSendNoRetry(queueName, msg = {}, limit = 0) {
116
- this.selfSend(queueName, {...msg, noRetry: true}, limit);
117
- }
118
-
119
- async getInfo(queueName) {
120
- const prefixQueueName = this.parsePrefix(queueName);
112
+ async getInfo(queueName, self = false) {
113
+ const prefixQueueName = this.parsePrefix(queueName, self);
121
114
 
122
115
  if (this.connected) {
123
116
  let channel;
@@ -138,10 +131,6 @@ class RabbitMQAsync {
138
131
  }
139
132
  }
140
133
 
141
- async getSelfInfo(queueName) {
142
- return this.getInfo(`${this.serverIp}_${queueName}`);
143
- }
144
-
145
134
  async consume(queueName, cb, callbackError = null) {
146
135
  const prefixQueueName = this.parsePrefix(queueName);
147
136
 
@@ -166,12 +155,8 @@ class RabbitMQAsync {
166
155
  if (data) {
167
156
  try {
168
157
  if (msg.fields.redelivered) {
169
- if (!data.retry) {
170
- data.retry = 0;
171
- }
172
- data.retry += 1;
173
-
174
- if (data.retry < 5) {
158
+ data.retry -= 1;
159
+ if (data.retry > 0) {
175
160
  if (messageQueue.worker && !queueName.startsWith(messageQueue.serverIp)) {
176
161
  await messageQueue.send(`${messageQueue.serverIp}_${queueName}`, data);
177
162
  } else {
@@ -198,7 +183,7 @@ class RabbitMQAsync {
198
183
  if (callbackError) {
199
184
  callbackError(prefixQueueName, err);
200
185
  }
201
- if (data.noRetry) {
186
+ if (data.retry <= 0) {
202
187
  await channel.ack(msg);
203
188
  } else {
204
189
  await channel.nack(msg);