@azteam/rabbitmq-async 1.0.123 → 1.0.124

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.124",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "engines": {
@@ -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,37 @@ 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
+ const queueInfo = await channel.assertQueue(prefixQueueName, {
109
+ durable: true,
110
+ });
111
+
112
+ return queueInfo;
113
+ } catch (err) {
114
+ return this.getInfo(queueName);
115
+ } finally {
116
+ try {
117
+ if (channel) {
118
+ channel.close();
119
+ }
120
+ } catch (err) {}
121
+ }
122
+ } else {
123
+ return this.getInfo(queueName);
124
+ }
125
+ }
126
+
101
127
  async receiving(queueName, cb, callbackError = null) {
102
128
  const prefixQueueName = this.parsePrefix(queueName);
103
129
 
@@ -106,9 +132,10 @@ class RabbitMQAsync {
106
132
  try {
107
133
  channel = await this.client.createChannel();
108
134
 
109
- await channel.assertQueue(prefixQueueName, {
135
+ const data = await channel.assertQueue(prefixQueueName, {
110
136
  durable: true,
111
137
  });
138
+
112
139
  await channel.prefetch(1);
113
140
 
114
141
  const messageQueue = this;