@autofleet/rabbit 1.0.17 → 1.0.19

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 CHANGED
@@ -45,9 +45,7 @@ class RabbitMq {
45
45
  try {
46
46
  connection = await this.getConnection();
47
47
  if (this.channel === null) {
48
- this.channel = connection.createChannel({
49
- json: true,
50
- });
48
+ this.channel = connection.createChannel({});
51
49
  }
52
50
  resolve(this.channel);
53
51
  }
@@ -71,7 +69,7 @@ class RabbitMq {
71
69
  return channel.addSetup((c) => {
72
70
  return Promise.all([
73
71
  c.prefetch(limit, false),
74
- c.consume(queue, (msg) => callback(msg, this.ack, this.nack(queue))),
72
+ c.consume(queue, (msg) => callback(JSON.parse(msg.toString()), this.ack, this.nack(queue))),
75
73
  ]);
76
74
  });
77
75
  }
@@ -86,19 +84,19 @@ class RabbitMq {
86
84
  return Promise.all([
87
85
  c.prefetch(limit, false),
88
86
  c.bindQueue(queue, exchange, ''),
89
- c.consume(queue, (msg) => callback(msg, this.ack, this.nack(queue))),
87
+ c.consume(queue, (msg) => callback(JSON.parse(msg.toString()), this.ack, this.nack(queue))),
90
88
  ]);
91
89
  });
92
90
  }
93
91
  async publish(exchange, content) {
94
92
  const channel = await this.assertChannel();
95
93
  await this.assertExchange(exchange);
96
- return channel.publish(exchange, '', Buffer.from(content));
94
+ return channel.publish(exchange, '', Buffer.from(JSON.stringify(content)));
97
95
  }
98
96
  async sendToQueue(queue, content) {
99
97
  const channel = await this.assertChannel();
100
98
  await this.assertQueue(queue);
101
- return channel.sendToQueue(queue, Buffer.from(content));
99
+ return channel.sendToQueue(queue, Buffer.from(JSON.stringify(content)));
102
100
  }
103
101
  }
104
102
  exports.default = RabbitMq;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -55,9 +55,7 @@ class RabbitMq {
55
55
  try {
56
56
  connection = await this.getConnection();
57
57
  if (this.channel === null) {
58
- this.channel = connection.createChannel({
59
- json: true,
60
- });
58
+ this.channel = connection.createChannel({});
61
59
  }
62
60
  resolve(this.channel);
63
61
  } catch (e) {
@@ -83,7 +81,7 @@ class RabbitMq {
83
81
  return channel.addSetup((c: ConfirmChannel) => {
84
82
  return Promise.all([
85
83
  c.prefetch(limit, false),
86
- c.consume(queue, (msg : any) => callback(msg, this.ack, this.nack(queue))),
84
+ c.consume(queue, (msg: any) => callback(JSON.parse(msg.toString()), this.ack, this.nack(queue))),
87
85
  ]);
88
86
  });
89
87
  }
@@ -100,7 +98,7 @@ class RabbitMq {
100
98
  return Promise.all([
101
99
  c.prefetch(limit, false),
102
100
  c.bindQueue(queue, exchange, ''),
103
- c.consume(queue, (msg : any) => callback(msg, this.ack, this.nack(queue))),
101
+ c.consume(queue, (msg: any) => callback(JSON.parse(msg.toString()), this.ack, this.nack(queue))),
104
102
  ])
105
103
  })
106
104
  }
@@ -108,13 +106,13 @@ class RabbitMq {
108
106
  async publish(exchange: string, content: any) {
109
107
  const channel: ChannelWrapper = await this.assertChannel();
110
108
  await this.assertExchange(exchange);
111
- return channel.publish(exchange, '', Buffer.from(content));
109
+ return channel.publish(exchange, '', Buffer.from(JSON.stringify(content)));
112
110
  }
113
111
 
114
112
  async sendToQueue(queue: string, content: any) {
115
113
  const channel: ChannelWrapper = await this.assertChannel();
116
114
  await this.assertQueue(queue);
117
- return channel.sendToQueue(queue, Buffer.from(content));
115
+ return channel.sendToQueue(queue, Buffer.from(JSON.stringify(content)));
118
116
  }
119
117
  }
120
118