@autofleet/rabbit 1.0.12 → 1.0.13

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
@@ -58,6 +58,14 @@ class RabbitMq {
58
58
  connection = await amqplib_1.connect(`amqp://${host}`);
59
59
  channel = await connection.createChannel();
60
60
  this.channel = channel;
61
+ channel.on('close', async () => {
62
+ this.channel = null;
63
+ await this.assertChannel();
64
+ });
65
+ connection.on('close', async () => {
66
+ this.channel = null;
67
+ await this.assertChannel();
68
+ });
61
69
  this.creatingChannel = false;
62
70
  this.em.emit(channelCreatedConst, channel);
63
71
  resolve(channel);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/rabbit",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { connect, Connection, Channel } from 'amqplib';
2
2
  import { EventEmitter } from 'events';
3
- import { reject } from 'bluebird';
4
3
 
5
4
  const channelCreatedConst: string = 'channelCreated';
6
5
  class RabbitMq {
@@ -71,6 +70,14 @@ class RabbitMq {
71
70
  connection = await connect(`amqp://${host}`);
72
71
  channel = await connection.createChannel();
73
72
  this.channel = channel;
73
+ channel.on('close', async () => {
74
+ this.channel = null;
75
+ await this.assertChannel();
76
+ });
77
+ connection.on('close', async () => {
78
+ this.channel = null;
79
+ await this.assertChannel();
80
+ });
74
81
  this.creatingChannel = false;
75
82
  this.em.emit(channelCreatedConst, channel);
76
83
  resolve(channel);