@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.
@@ -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 = 50;
351
+ _context6.next = 51;
352
352
  break;
353
353
  }
354
354
  data = JSON.parse(msg.content.toString());
355
355
  if (!data) {
356
- _context6.next = 47;
356
+ _context6.next = 48;
357
357
  break;
358
358
  }
359
359
  _context6.prev = 3;
360
360
  if (!msg.fields.redelivered) {
361
- _context6.next = 18;
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 = 12;
369
+ _context6.next = 13;
370
370
  break;
371
371
  }
372
- _context6.next = 10;
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 10:
375
- _context6.next = 14;
377
+ case 11:
378
+ _context6.next = 15;
376
379
  break;
377
- case 12:
378
- _context6.next = 14;
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 14:
385
- _context6.next = 16;
387
+ case 15:
388
+ _context6.next = 17;
386
389
  return channel.ack(msg);
387
- case 16:
388
- _context6.next = 40;
390
+ case 17:
391
+ _context6.next = 41;
389
392
  break;
390
- case 18:
391
- _context6.prev = 18;
392
- _context6.next = 21;
393
+ case 19:
394
+ _context6.prev = 19;
395
+ _context6.next = 22;
393
396
  return cb(data);
394
- case 21:
395
- _context6.next = 23;
397
+ case 22:
398
+ _context6.next = 24;
396
399
  return channel.ack(msg);
397
- case 23:
398
- _context6.next = 40;
400
+ case 24:
401
+ _context6.next = 41;
399
402
  break;
400
- case 25:
401
- _context6.prev = 25;
402
- _context6.t0 = _context6["catch"](18);
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 = 32;
410
+ _context6.next = 33;
408
411
  break;
409
412
  }
410
413
  reject(new Error(errString));
411
- _context6.next = 40;
414
+ _context6.next = 41;
412
415
  break;
413
- case 32:
416
+ case 33:
414
417
  if (callbackError) {
415
418
  callbackError(prefixQueueName, _context6.t0);
416
419
  }
417
420
  if (!data.noRetry) {
418
- _context6.next = 38;
421
+ _context6.next = 39;
419
422
  break;
420
423
  }
421
- _context6.next = 36;
424
+ _context6.next = 37;
422
425
  return channel.ack(msg);
423
- case 36:
424
- _context6.next = 40;
426
+ case 37:
427
+ _context6.next = 41;
425
428
  break;
426
- case 38:
427
- _context6.next = 40;
429
+ case 39:
430
+ _context6.next = 41;
428
431
  return channel.nack(msg);
429
- case 40:
430
- _context6.next = 45;
432
+ case 41:
433
+ _context6.next = 46;
431
434
  break;
432
- case 42:
433
- _context6.prev = 42;
435
+ case 43:
436
+ _context6.prev = 43;
434
437
  _context6.t1 = _context6["catch"](3);
435
438
  reject(_context6.t1);
436
- case 45:
437
- _context6.next = 48;
439
+ case 46:
440
+ _context6.next = 49;
438
441
  break;
439
- case 47:
440
- channel.ack(msg);
441
442
  case 48:
442
- _context6.next = 51;
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, 42], [18, 25]]);
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/rabbitmq-async",
3
- "version": "1.0.161",
3
+ "version": "1.0.162",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./src/index.js",
@@ -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'), {