@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 +1 -1
- package/src/RabbitMQAsync.js +30 -3
package/package.json
CHANGED
package/src/RabbitMQAsync.js
CHANGED
|
@@ -83,7 +83,7 @@ class RabbitMQAsync {
|
|
|
83
83
|
|
|
84
84
|
return true;
|
|
85
85
|
} catch (err) {
|
|
86
|
-
await timeout(
|
|
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(
|
|
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;
|