@azteam/rabbitmq-async 1.0.167 → 1.0.169

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,253 @@ 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 = 49;
458
366
  break;
459
367
  }
460
368
  data = JSON.parse(msg.content.toString());
461
369
  if (!data) {
462
- _context10.next = 52;
370
+ _context6.next = 46;
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 = 17;
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;
476
- break;
477
- }
478
- if (!(messageQueue.worker && !queueName.startsWith(messageQueue.serverIp))) {
479
- _context10.next = 13;
378
+ data.retry -= 1;
379
+ if (!(data.retry > 0)) {
380
+ _context6.next = 11;
480
381
  break;
481
382
  }
482
- _context10.next = 11;
483
- return messageQueue.send("".concat(messageQueue.serverIp, "_").concat(queueName), data);
484
- case 11:
485
- _context10.next = 15;
486
- break;
487
- case 13:
488
- _context10.next = 15;
383
+ _context6.next = 9;
489
384
  return messageQueue.send(queueName, data);
490
- case 15:
491
- _context10.next = 19;
385
+ case 9:
386
+ _context6.next = 13;
492
387
  break;
493
- case 17:
494
- _context10.next = 19;
388
+ case 11:
389
+ _context6.next = 13;
495
390
  return messageQueue.send(messageQueue.parsePrefix('RETRY'), {
496
391
  queueName: queueName,
497
392
  data: data,
498
393
  retry_time: new Date()
499
394
  });
500
- case 19:
501
- _context10.next = 21;
395
+ case 13:
396
+ _context6.next = 15;
502
397
  return channel.ack(msg);
503
- case 21:
504
- _context10.next = 45;
398
+ case 15:
399
+ _context6.next = 39;
505
400
  break;
506
- case 23:
507
- _context10.prev = 23;
508
- _context10.next = 26;
401
+ case 17:
402
+ _context6.prev = 17;
403
+ _context6.next = 20;
509
404
  return cb(data);
510
- case 26:
511
- _context10.next = 28;
405
+ case 20:
406
+ _context6.next = 22;
512
407
  return channel.ack(msg);
513
- case 28:
514
- _context10.next = 45;
408
+ case 22:
409
+ _context6.next = 39;
515
410
  break;
516
- case 30:
517
- _context10.prev = 30;
518
- _context10.t0 = _context10["catch"](23);
519
- errString = _context10.t0.toString();
411
+ case 24:
412
+ _context6.prev = 24;
413
+ _context6.t0 = _context6["catch"](17);
414
+ errString = _context6.t0.toString();
520
415
  if (!_lodash["default"].some(['IllegalOperationError: Channel closed'], function (el) {
521
416
  return _lodash["default"].includes(errString, el);
522
417
  })) {
523
- _context10.next = 37;
418
+ _context6.next = 31;
524
419
  break;
525
420
  }
526
421
  reject(new Error(errString));
527
- _context10.next = 45;
422
+ _context6.next = 39;
528
423
  break;
529
- case 37:
424
+ case 31:
530
425
  if (callbackError) {
531
- callbackError(prefixQueueName, _context10.t0);
426
+ callbackError(prefixQueueName, _context6.t0);
532
427
  }
533
- if (!data.noRetry) {
534
- _context10.next = 43;
428
+ if (!(data.retry <= 0)) {
429
+ _context6.next = 37;
535
430
  break;
536
431
  }
537
- _context10.next = 41;
432
+ _context6.next = 35;
538
433
  return channel.ack(msg);
539
- case 41:
540
- _context10.next = 45;
434
+ case 35:
435
+ _context6.next = 39;
541
436
  break;
542
- case 43:
543
- _context10.next = 45;
437
+ case 37:
438
+ _context6.next = 39;
544
439
  return channel.nack(msg);
545
- case 45:
546
- _context10.next = 50;
440
+ case 39:
441
+ _context6.next = 44;
547
442
  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;
443
+ case 41:
444
+ _context6.prev = 41;
445
+ _context6.t1 = _context6["catch"](3);
446
+ reject(_context6.t1);
447
+ case 44:
448
+ _context6.next = 47;
554
449
  break;
555
- case 52:
450
+ case 46:
556
451
  channel.ack(msg);
557
- case 53:
558
- _context10.next = 56;
452
+ case 47:
453
+ _context6.next = 50;
559
454
  break;
560
- case 55:
455
+ case 49:
561
456
  reject(new Error('msg null'));
562
- case 56:
457
+ case 50:
563
458
  case "end":
564
- return _context10.stop();
459
+ return _context6.stop();
565
460
  }
566
461
  }
567
- }, _callee10, null, [[3, 47], [23, 30]]);
462
+ }, _callee6, null, [[3, 41], [17, 24]]);
568
463
  }));
569
- return function (_x9) {
464
+ return function (_x5) {
570
465
  return _ref.apply(this, arguments);
571
466
  };
572
467
  }());
573
468
  });
574
469
  case 14:
575
- _context11.next = 28;
470
+ _context7.next = 28;
576
471
  break;
577
472
  case 16:
578
- _context11.prev = 16;
579
- _context11.t0 = _context11["catch"](3);
580
- _context11.prev = 18;
581
- _context11.next = 21;
473
+ _context7.prev = 16;
474
+ _context7.t0 = _context7["catch"](3);
475
+ _context7.prev = 18;
476
+ _context7.next = 21;
582
477
  return channel.close();
583
478
  case 21:
584
- _context11.next = 25;
479
+ _context7.next = 25;
585
480
  break;
586
481
  case 23:
587
- _context11.prev = 23;
588
- _context11.t1 = _context11["catch"](18);
482
+ _context7.prev = 23;
483
+ _context7.t1 = _context7["catch"](18);
589
484
  case 25:
590
- _context11.next = 27;
485
+ _context7.next = 27;
591
486
  return (0, _util.timeout)(5000);
592
487
  case 27:
593
- return _context11.abrupt("return", this.consume(queueName, cb, callbackError));
488
+ return _context7.abrupt("return", this.consume(queueName, cb, callbackError));
594
489
  case 28:
595
- _context11.next = 33;
490
+ _context7.next = 33;
596
491
  break;
597
492
  case 30:
598
- _context11.next = 32;
493
+ _context7.next = 32;
599
494
  return (0, _util.timeout)(5000);
600
495
  case 32:
601
- return _context11.abrupt("return", this.consume(queueName, cb, callbackError));
496
+ return _context7.abrupt("return", this.consume(queueName, cb, callbackError));
602
497
  case 33:
603
- return _context11.abrupt("return", true);
498
+ return _context7.abrupt("return", true);
604
499
  case 34:
605
500
  case "end":
606
- return _context11.stop();
501
+ return _context7.stop();
607
502
  }
608
503
  }
609
- }, _callee11, this, [[3, 16], [18, 23]]);
504
+ }, _callee7, this, [[3, 16], [18, 23]]);
610
505
  }));
611
- function consume(_x7, _x8) {
506
+ function consume(_x3, _x4) {
612
507
  return _consume.apply(this, arguments);
613
508
  }
614
509
  return consume;
@@ -616,20 +511,20 @@ var RabbitMQAsync = /*#__PURE__*/function () {
616
511
  }, {
617
512
  key: "selfReceiving",
618
513
  value: function () {
619
- var _selfReceiving = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(queueName, cb, callbackError) {
620
- return _regeneratorRuntime().wrap(function _callee12$(_context12) {
514
+ var _selfReceiving = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(queueName, cb, callbackError) {
515
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
621
516
  while (1) {
622
- switch (_context12.prev = _context12.next) {
517
+ switch (_context8.prev = _context8.next) {
623
518
  case 0:
624
519
  this.consume("".concat(this.serverIp, "_").concat(queueName), cb, callbackError);
625
520
  case 1:
626
521
  case "end":
627
- return _context12.stop();
522
+ return _context8.stop();
628
523
  }
629
524
  }
630
- }, _callee12, this);
525
+ }, _callee8, this);
631
526
  }));
632
- function selfReceiving(_x10, _x11, _x12) {
527
+ function selfReceiving(_x6, _x7, _x8) {
633
528
  return _selfReceiving.apply(this, arguments);
634
529
  }
635
530
  return selfReceiving;
@@ -637,26 +532,26 @@ var RabbitMQAsync = /*#__PURE__*/function () {
637
532
  }, {
638
533
  key: "receiving",
639
534
  value: function () {
640
- var _receiving = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee13(queueName, cb) {
535
+ var _receiving = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(queueName, cb) {
641
536
  var callbackError,
642
- _args13 = arguments;
643
- return _regeneratorRuntime().wrap(function _callee13$(_context13) {
537
+ _args9 = arguments;
538
+ return _regeneratorRuntime().wrap(function _callee9$(_context9) {
644
539
  while (1) {
645
- switch (_context13.prev = _context13.next) {
540
+ switch (_context9.prev = _context9.next) {
646
541
  case 0:
647
- callbackError = _args13.length > 2 && _args13[2] !== undefined ? _args13[2] : null;
542
+ callbackError = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : null;
648
543
  this.consume(queueName, cb, callbackError);
649
544
  if (this.worker) {
650
545
  this.selfReceiving(queueName, cb, callbackError);
651
546
  }
652
547
  case 3:
653
548
  case "end":
654
- return _context13.stop();
549
+ return _context9.stop();
655
550
  }
656
551
  }
657
- }, _callee13, this);
552
+ }, _callee9, this);
658
553
  }));
659
- function receiving(_x13, _x14) {
554
+ function receiving(_x9, _x10) {
660
555
  return _receiving.apply(this, arguments);
661
556
  }
662
557
  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.169",
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,17 +155,9 @@ 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) {
175
- if (messageQueue.worker && !queueName.startsWith(messageQueue.serverIp)) {
176
- await messageQueue.send(`${messageQueue.serverIp}_${queueName}`, data);
177
- } else {
178
- await messageQueue.send(queueName, data);
179
- }
158
+ data.retry -= 1;
159
+ if (data.retry > 0) {
160
+ await messageQueue.send(queueName, data);
180
161
  } else {
181
162
  await messageQueue.send(messageQueue.parsePrefix('RETRY'), {
182
163
  queueName,
@@ -198,7 +179,7 @@ class RabbitMQAsync {
198
179
  if (callbackError) {
199
180
  callbackError(prefixQueueName, err);
200
181
  }
201
- if (data.noRetry) {
182
+ if (data.retry <= 0) {
202
183
  await channel.ack(msg);
203
184
  } else {
204
185
  await channel.nack(msg);