@azteam/rabbitmq-async 1.0.208 → 1.0.209

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.
@@ -209,40 +209,46 @@ var RabbitMQAsync = /*#__PURE__*/function () {
209
209
  _context5.prev = 2;
210
210
  prefixQueueName = this.parsePrefix(queueName);
211
211
  if (!this.connected) {
212
- _context5.next = 12;
212
+ _context5.next = 16;
213
213
  break;
214
214
  }
215
- channel = this.channel;
216
- _context5.next = 8;
215
+ _context5.next = 7;
216
+ return this.client.createChannel();
217
+ case 7:
218
+ channel = _context5.sent;
219
+ _context5.next = 10;
217
220
  return this.channel.assertQueue(prefixQueueName, {
218
221
  durable: true
219
222
  });
220
- case 8:
223
+ case 10:
221
224
  queueInfo = _context5.sent;
222
225
  if (!(limit === 0 || queueInfo.messageCount < limit)) {
223
- _context5.next = 12;
226
+ _context5.next = 16;
224
227
  break;
225
228
  }
226
- _context5.next = 12;
229
+ _context5.next = 14;
227
230
  return channel.sendToQueue(prefixQueueName, Buffer.from(JSON.stringify(_objectSpread({
228
231
  retry: 5
229
232
  }, msg))), {
230
233
  persistent: true
231
234
  });
232
- case 12:
235
+ case 14:
236
+ _context5.next = 16;
237
+ return channel.close();
238
+ case 16:
233
239
  return _context5.abrupt("return", true);
234
- case 15:
235
- _context5.prev = 15;
240
+ case 19:
241
+ _context5.prev = 19;
236
242
  _context5.t0 = _context5["catch"](2);
237
- _context5.next = 19;
243
+ _context5.next = 23;
238
244
  return (0, _util.timeout)(2000);
239
- case 19:
245
+ case 23:
240
246
  return _context5.abrupt("return", this.send(queueName, msg));
241
- case 20:
247
+ case 24:
242
248
  case "end":
243
249
  return _context5.stop();
244
250
  }
245
- }, _callee5, this, [[2, 15]]);
251
+ }, _callee5, this, [[2, 19]]);
246
252
  }));
247
253
  function send(_x) {
248
254
  return _send.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/rabbitmq-async",
3
- "version": "1.0.208",
3
+ "version": "1.0.209",
4
4
  "description": "N/A",
5
5
  "keywords": [
6
6
  "toda",
@@ -85,7 +85,7 @@ class RabbitMQAsync {
85
85
  try {
86
86
  const prefixQueueName = this.parsePrefix(queueName);
87
87
  if (this.connected) {
88
- const {channel} = this,
88
+ const channel = await this.client.createChannel(),
89
89
  queueInfo = await this.channel.assertQueue(prefixQueueName, {
90
90
  durable: true,
91
91
  });
@@ -94,6 +94,7 @@ class RabbitMQAsync {
94
94
  await channel.sendToQueue(prefixQueueName, Buffer.from(JSON.stringify({retry: 5, ...msg})), {
95
95
  persistent: true,
96
96
  });
97
+ await channel.close();
97
98
  }
98
99
  }
99
100