@azteam/rabbitmq-async 1.0.123 → 1.0.134

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azteam/rabbitmq-async",
3
- "version": "1.0.123",
3
+ "version": "1.0.134",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "engines": {
@@ -17,6 +17,6 @@
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
19
  "@azteam/util": "1.0.13",
20
- "amqplib": "0.10.1"
20
+ "amqplib": "0.8.0"
21
21
  }
22
22
  }
@@ -83,7 +83,7 @@ class RabbitMQAsync {
83
83
 
84
84
  return true;
85
85
  } catch (err) {
86
- await timeout(5000);
86
+ await timeout(2000);
87
87
  return this.send(queueName, msg);
88
88
  } finally {
89
89
  try {
@@ -93,11 +93,35 @@ class RabbitMQAsync {
93
93
  } catch (err) {}
94
94
  }
95
95
  } else {
96
- await timeout(5000);
96
+ await timeout(2000);
97
97
  return this.send(queueName, msg);
98
98
  }
99
99
  }
100
100
 
101
+ async getInfo(queueName) {
102
+ const prefixQueueName = this.parsePrefix(queueName);
103
+
104
+ if (this.connected) {
105
+ let channel = null;
106
+ try {
107
+ channel = await this.client.createChannel();
108
+ return await channel.assertQueue(prefixQueueName, {
109
+ durable: true,
110
+ });
111
+ } catch (err) {
112
+ return this.getInfo(queueName);
113
+ } finally {
114
+ try {
115
+ if (channel) {
116
+ channel.close();
117
+ }
118
+ } catch (err) {}
119
+ }
120
+ } else {
121
+ return this.getInfo(queueName);
122
+ }
123
+ }
124
+
101
125
  async receiving(queueName, cb, callbackError = null) {
102
126
  const prefixQueueName = this.parsePrefix(queueName);
103
127
 
@@ -109,6 +133,7 @@ class RabbitMQAsync {
109
133
  await channel.assertQueue(prefixQueueName, {
110
134
  durable: true,
111
135
  });
136
+
112
137
  await channel.prefetch(1);
113
138
 
114
139
  const messageQueue = this;