@autofleet/rabbit 1.5.5 → 1.5.6
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/dist/index.js +8 -4
- package/package.json +1 -1
- package/src/index.ts +14 -4
package/dist/index.js
CHANGED
|
@@ -161,7 +161,6 @@ class RabbitMq {
|
|
|
161
161
|
}
|
|
162
162
|
consume(queue, callback, options) {
|
|
163
163
|
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
-
outbreak_1.newTrace(outbreak_1.traceTypes.RABBIT);
|
|
165
164
|
RabbitMq.validateName('queue', queue);
|
|
166
165
|
const { limit } = (options && options.limit) ? options : { limit: 1 };
|
|
167
166
|
const channel = yield this.assertChannel();
|
|
@@ -169,14 +168,16 @@ class RabbitMq {
|
|
|
169
168
|
yield c.assertQueue(queue);
|
|
170
169
|
yield c.prefetch(limit, true);
|
|
171
170
|
return Promise.all([
|
|
172
|
-
c.consume(queue, (msg) =>
|
|
171
|
+
c.consume(queue, (msg) => {
|
|
172
|
+
outbreak_1.newTrace(outbreak_1.traceTypes.RABBIT);
|
|
173
|
+
callback(RabbitMq.parseMsg(msg), this.ack, this.nack(queue));
|
|
174
|
+
}),
|
|
173
175
|
]);
|
|
174
176
|
}));
|
|
175
177
|
});
|
|
176
178
|
}
|
|
177
179
|
consumeFromExchange(queue, exchange, callback, options) {
|
|
178
180
|
return __awaiter(this, void 0, void 0, function* () {
|
|
179
|
-
outbreak_1.newTrace(outbreak_1.traceTypes.RABBIT);
|
|
180
181
|
RabbitMq.validateName('queue', queue);
|
|
181
182
|
RabbitMq.validateName('exchange', exchange);
|
|
182
183
|
const { limit } = (options && options.limit) ? options : { limit: 1 };
|
|
@@ -188,7 +189,10 @@ class RabbitMq {
|
|
|
188
189
|
yield c.prefetch(limit, true);
|
|
189
190
|
return Promise.all([
|
|
190
191
|
c.bindQueue(queue, exchange, ''),
|
|
191
|
-
c.consume(queue, (msg) =>
|
|
192
|
+
c.consume(queue, (msg) => {
|
|
193
|
+
outbreak_1.newTrace(outbreak_1.traceTypes.RABBIT);
|
|
194
|
+
callback(RabbitMq.parseMsg(msg), this.ack, this.nack(queue));
|
|
195
|
+
}),
|
|
192
196
|
]);
|
|
193
197
|
}));
|
|
194
198
|
});
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -151,7 +151,6 @@ class RabbitMq {
|
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
async consume(queue: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any) {
|
|
154
|
-
newTrace(traceTypes.RABBIT);
|
|
155
154
|
RabbitMq.validateName('queue', queue);
|
|
156
155
|
const { limit } = (options && options.limit) ? options : { limit: 1 };
|
|
157
156
|
const channel: ChannelWrapper = await this.assertChannel();
|
|
@@ -159,13 +158,18 @@ class RabbitMq {
|
|
|
159
158
|
await c.assertQueue(queue);
|
|
160
159
|
await c.prefetch(limit, true);
|
|
161
160
|
return Promise.all([
|
|
162
|
-
c.consume(
|
|
161
|
+
c.consume(
|
|
162
|
+
queue,
|
|
163
|
+
(msg: any) => {
|
|
164
|
+
newTrace(traceTypes.RABBIT);
|
|
165
|
+
callback(RabbitMq.parseMsg(msg), this.ack, this.nack(queue));
|
|
166
|
+
},
|
|
167
|
+
),
|
|
163
168
|
]);
|
|
164
169
|
});
|
|
165
170
|
}
|
|
166
171
|
|
|
167
172
|
async consumeFromExchange(queue: string, exchange: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any) {
|
|
168
|
-
newTrace(traceTypes.RABBIT);
|
|
169
173
|
RabbitMq.validateName('queue', queue);
|
|
170
174
|
RabbitMq.validateName('exchange', exchange);
|
|
171
175
|
const { limit } = (options && options.limit) ? options : { limit: 1 };
|
|
@@ -178,7 +182,13 @@ class RabbitMq {
|
|
|
178
182
|
await c.prefetch(limit, true);
|
|
179
183
|
return Promise.all([
|
|
180
184
|
c.bindQueue(queue, exchange, ''),
|
|
181
|
-
c.consume(
|
|
185
|
+
c.consume(
|
|
186
|
+
queue,
|
|
187
|
+
(msg: any) => {
|
|
188
|
+
newTrace(traceTypes.RABBIT);
|
|
189
|
+
callback(RabbitMq.parseMsg(msg), this.ack, this.nack(queue));
|
|
190
|
+
},
|
|
191
|
+
),
|
|
182
192
|
]);
|
|
183
193
|
});
|
|
184
194
|
}
|