easywork-common-lib 1.0.751 → 1.0.753

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.
@@ -2,6 +2,8 @@ import { AmqpConnection } from "@golevelup/nestjs-rabbitmq";
2
2
  export declare class EasyQueueService {
3
3
  private readonly amqpConnection;
4
4
  private readonly exchangeName;
5
+ private readonly logger;
5
6
  constructor(amqpConnection: AmqpConnection, exchangeName: string);
6
- publishMessage(routingKey: string, message: any): Promise<void>;
7
+ publishMessage(routingKey: string, message: any): Promise<boolean>;
8
+ checkConnection(): Promise<boolean>;
7
9
  }
@@ -11,25 +11,44 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var __param = (this && this.__param) || function (paramIndex, decorator) {
12
12
  return function (target, key) { decorator(target, key, paramIndex); }
13
13
  };
14
+ var EasyQueueService_1;
14
15
  Object.defineProperty(exports, "__esModule", { value: true });
15
16
  exports.EasyQueueService = void 0;
16
17
  const nestjs_rabbitmq_1 = require("@golevelup/nestjs-rabbitmq");
17
18
  const common_1 = require("@nestjs/common");
18
- const logger = new common_1.Logger("EasyQueueService");
19
- let EasyQueueService = class EasyQueueService {
19
+ let EasyQueueService = EasyQueueService_1 = class EasyQueueService {
20
20
  amqpConnection;
21
21
  exchangeName;
22
+ logger = new common_1.Logger(EasyQueueService_1.name);
22
23
  constructor(amqpConnection, exchangeName) {
23
24
  this.amqpConnection = amqpConnection;
24
25
  this.exchangeName = exchangeName;
25
26
  }
26
27
  async publishMessage(routingKey, message) {
27
- logger.debug(`Publishing Message on the queue... ${this.exchangeName}, ${routingKey}`);
28
- await this.amqpConnection.publish(this.exchangeName, routingKey, message);
28
+ try {
29
+ this.logger.debug(`Publishing message to exchange: ${this.exchangeName}, routing key: ${routingKey}`);
30
+ await this.amqpConnection.publish(this.exchangeName, routingKey, message, { persistent: true });
31
+ this.logger.debug(`Message published successfully`);
32
+ return true;
33
+ }
34
+ catch (error) {
35
+ this.logger.error(`Error publishing message to ${routingKey}: ${error.message}`, error.stack);
36
+ return false;
37
+ }
38
+ }
39
+ async checkConnection() {
40
+ try {
41
+ const channel = this.amqpConnection.channel;
42
+ return !!channel;
43
+ }
44
+ catch (error) {
45
+ this.logger.error(`Error checking RabbitMQ connection: ${error.message}`);
46
+ return false;
47
+ }
29
48
  }
30
49
  };
31
50
  exports.EasyQueueService = EasyQueueService;
32
- exports.EasyQueueService = EasyQueueService = __decorate([
51
+ exports.EasyQueueService = EasyQueueService = EasyQueueService_1 = __decorate([
33
52
  (0, common_1.Injectable)(),
34
53
  __param(1, (0, common_1.Inject)('EXCHANGE_NAME')),
35
54
  __metadata("design:paramtypes", [nestjs_rabbitmq_1.AmqpConnection, String])
@@ -1 +1 @@
1
- {"version":3,"file":"queue.service.js","sourceRoot":"","sources":["../../../src/modules/queue/queue.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gEAA4D;AAC5D,2CAA4D;AAE5D,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,kBAAkB,CAAC,CAAC;AAGvC,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAEJ;IACyB;IAF9C,YACqB,cAA8B,EACL,YAAoB;QAD7C,mBAAc,GAAd,cAAc,CAAgB;QACL,iBAAY,GAAZ,YAAY,CAAQ;IAC9D,CAAC;IAEL,KAAK,CAAC,cAAc,CAAC,UAAkB,EAAE,OAAY;QACnD,MAAM,CAAC,KAAK,CAAC,sCAAsC,IAAI,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC,CAAC;QACvF,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC5E,CAAC;CACJ,CAAA;AAVY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAIJ,WAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;qCADS,gCAAc;GAF1C,gBAAgB,CAU5B"}
1
+ {"version":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C1E,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;CACJ,CAAA;AAxCY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;IAMJ,WAAA,IAAA,eAAM,EAAC,eAAe,CAAC,CAAA;qCADS,gCAAc;GAJ1C,gBAAgB,CAwC5B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easywork-common-lib",
3
- "version": "1.0.751",
3
+ "version": "1.0.753",
4
4
  "description": "Librería común de Easywork",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {