@autofleet/rabbit 2.1.8-beta6 → 2.1.8

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.d.ts CHANGED
@@ -50,13 +50,13 @@ declare class RabbitMq implements IAfRabbitMq {
50
50
  getNewChannel(): Promise<ChannelWrapper>;
51
51
  assertChannel(): Promise<ChannelWrapper>;
52
52
  assertExchange(exchangeName: string, options?: any): Promise<any>;
53
- getQueueLength(queue: string): Promise<import("amqplib").Replies.AssertQueue>;
54
- bindQueue(queue: string, exchange: string): Promise<void>;
53
+ getQueueLength(queue: string): Promise<any>;
54
+ bindQueue(queue: string, exchange: string): Promise<any>;
55
55
  assertQueue(queue: string, options?: Options.AssertQueue): Promise<void>;
56
56
  consume(queue: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any): Promise<void>;
57
57
  consumeFromExchange(queue: string, exchange: string, callback: (msg: any, ack: Function, nack: Function) => any, options?: any): Promise<void>;
58
58
  publish(exchange: string, content: any, customHeaders?: any): Promise<unknown>;
59
- sendToQueue(queue: string, content: any, options?: any, customHeaders?: any): Promise<boolean>;
59
+ sendToQueue(queue: string, content: any, options?: any, customHeaders?: any): Promise<void>;
60
60
  isConnected(): Promise<boolean>;
61
61
  }
62
62
  export default RabbitMq;
package/dist/index.js CHANGED
@@ -37,7 +37,7 @@ const bluebird = __importStar(require("bluebird"));
37
37
  const moment_1 = __importDefault(require("moment"));
38
38
  const amqp_connection_manager_1 = require("amqp-connection-manager");
39
39
  const events_1 = require("events");
40
- // import { newTrace, traceTypes } from '@autofleet/outbreak';
40
+ const outbreak_1 = require("@autofleet/outbreak");
41
41
  const logger_1 = __importDefault(require("./logger"));
42
42
  const rabbitError_1 = __importDefault(require("./rabbitError"));
43
43
  const redis_1 = __importDefault(require("./redis"));
@@ -123,7 +123,7 @@ class RabbitMq {
123
123
  return __awaiter(this, void 0, void 0, function* () {
124
124
  return new Promise((resolve) => __awaiter(this, void 0, void 0, function* () {
125
125
  if (this.creatingConnection) {
126
- this.em.once(connectionCreatedConst, resolve);
126
+ this.em.on(connectionCreatedConst, resolve);
127
127
  return;
128
128
  }
129
129
  if (this.connection !== null) {
@@ -163,8 +163,8 @@ class RabbitMq {
163
163
  if (this.channel) {
164
164
  return resolve(this.channel);
165
165
  }
166
+ const connection = yield this.getConnection();
166
167
  try {
167
- const connection = yield this.getConnection();
168
168
  if (this.channel === null) {
169
169
  this.channel = connection.createChannel({});
170
170
  }
@@ -223,18 +223,13 @@ class RabbitMq {
223
223
  return Promise.all([
224
224
  c.consume(queue, (msg) => __awaiter(this, void 0, void 0, function* () {
225
225
  const parsedMessage = RabbitMq.parseMsg(msg);
226
- // newTrace(traceTypes.RABBIT);
226
+ outbreak_1.newTrace(outbreak_1.traceTypes.RABBIT);
227
227
  const shouldConsume = yield this.shouldConsumeMessageByTimestamp(parsedMessage);
228
228
  logger_1.default.info('rabbit: trying to consume', { queue, shouldConsume, msg });
229
229
  if (!shouldConsume) {
230
230
  return this.ack(channel)(msg);
231
231
  }
232
- try {
233
- yield callback(parsedMessage, this.ack(channel, true), this.nack(channel, queue, optionsWithDefaults, { messageTtl: deadMessageTtl }));
234
- }
235
- catch (e) {
236
- yield this.nack(channel, queue, optionsWithDefaults, { messageTtl: deadMessageTtl });
237
- }
232
+ callback(parsedMessage, this.ack(channel, true), this.nack(channel, queue, optionsWithDefaults, { messageTtl: deadMessageTtl }));
238
233
  })),
239
234
  ]);
240
235
  }));
@@ -256,7 +251,7 @@ class RabbitMq {
256
251
  c.bindQueue(queue, exchange, ''),
257
252
  c.consume(queue, (msg) => __awaiter(this, void 0, void 0, function* () {
258
253
  const parsedMessage = RabbitMq.parseMsg(msg);
259
- // newTrace(traceTypes.RABBIT);
254
+ outbreak_1.newTrace(outbreak_1.traceTypes.RABBIT);
260
255
  const shouldConsume = yield this.shouldConsumeMessageByTimestamp(parsedMessage);
261
256
  logger_1.default.info('rabbit: trying to consume', { queue, shouldConsume, msg });
262
257
  if (!shouldConsume) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "2.1.8-beta6",
3
+ "version": "2.1.8",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
@@ -19,7 +19,7 @@
19
19
  "@types/amqp-connection-manager": "^2.0.10",
20
20
  "@types/amqplib": "^0.5.16",
21
21
  "@types/uuid": "^8.3.3",
22
- "amqp-connection-manager": "^3.7.0",
22
+ "amqp-connection-manager": "^3.2.1",
23
23
  "amqplib": "^0.6.0",
24
24
  "bluebird": "^3.7.2",
25
25
  "moment": "^2.29.1",
package/src/index.ts CHANGED
@@ -5,7 +5,7 @@ import moment from 'moment';
5
5
  import { ConfirmChannel, Options } from 'amqplib';
6
6
  import { AmqpConnectionManager, ChannelWrapper, connect } from 'amqp-connection-manager';
7
7
  import { EventEmitter } from 'events';
8
- // import { newTrace, traceTypes } from '@autofleet/outbreak';
8
+ import { newTrace, traceTypes } from '@autofleet/outbreak';
9
9
  import logger from './logger';
10
10
  import RabbitError from './rabbitError';
11
11
  import getRedisInstance, { RedisConfig } from './redis';
@@ -159,7 +159,7 @@ class RabbitMq implements IAfRabbitMq {
159
159
  async getConnection() {
160
160
  return new Promise<AmqpConnectionManager>(async (resolve) => {
161
161
  if (this.creatingConnection) {
162
- this.em.once(connectionCreatedConst, resolve);
162
+ this.em.on(connectionCreatedConst, resolve);
163
163
  return;
164
164
  }
165
165
  if (this.connection !== null) {
@@ -197,8 +197,9 @@ class RabbitMq implements IAfRabbitMq {
197
197
  return resolve(this.channel);
198
198
  }
199
199
 
200
+ const connection: AmqpConnectionManager = await this.getConnection();
201
+
200
202
  try {
201
- const connection: AmqpConnectionManager = await this.getConnection();
202
203
  if (this.channel === null) {
203
204
  this.channel = connection.createChannel({});
204
205
  }
@@ -253,21 +254,13 @@ class RabbitMq implements IAfRabbitMq {
253
254
  queue,
254
255
  async (msg: any) => {
255
256
  const parsedMessage = RabbitMq.parseMsg(msg);
256
- // newTrace(traceTypes.RABBIT);
257
+ newTrace(traceTypes.RABBIT);
257
258
  const shouldConsume = await this.shouldConsumeMessageByTimestamp(parsedMessage);
258
259
  logger.info('rabbit: trying to consume', { queue, shouldConsume, msg });
259
260
  if (!shouldConsume) {
260
261
  return this.ack(channel)(msg);
261
262
  }
262
- try {
263
- await callback(
264
- parsedMessage,
265
- this.ack(channel, true),
266
- this.nack(channel, queue, optionsWithDefaults, { messageTtl: deadMessageTtl }),
267
- );
268
- } catch (e) {
269
- await this.nack(channel, queue, optionsWithDefaults, { messageTtl: deadMessageTtl });
270
- }
263
+ callback(parsedMessage, this.ack(channel, true), this.nack(channel, queue, optionsWithDefaults, { messageTtl: deadMessageTtl }));
271
264
  },
272
265
  ),
273
266
  ]);
@@ -292,7 +285,7 @@ class RabbitMq implements IAfRabbitMq {
292
285
  queue,
293
286
  async (msg: any) => {
294
287
  const parsedMessage = RabbitMq.parseMsg(msg);
295
- // newTrace(traceTypes.RABBIT);
288
+ newTrace(traceTypes.RABBIT);
296
289
  const shouldConsume = await this.shouldConsumeMessageByTimestamp(parsedMessage);
297
290
  logger.info('rabbit: trying to consume', { queue, shouldConsume, msg });
298
291
  if (!shouldConsume) {
package/.env DELETED
File without changes
package/dump.rdb DELETED
Binary file