Skip to content

Commit 22c1356

Browse files
committed
Fix reconnection using once instead of on
1 parent 66f7db8 commit 22c1356

4 files changed

Lines changed: 7 additions & 6 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,6 +453,8 @@ To set up your development environment:
453453
[Back to top](#table-of-contents)
454454

455455
## Change History
456+
* v1.5.1 (2018-09-24)
457+
* Fix reconnection error: use once instad of on and rebind event correctly
456458
* v1.5.0 (2018-08-24)
457459
* Add possibility to provide a custom MessageRouter
458460
* v1.4.3 (2018-08-20)

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hapiness/rabbitmq",
3-
"version": "1.5.0",
3+
"version": "1.5.1",
44
"description": "Hapiness module for rabbitmq",
55
"main": "commonjs/index.js",
66
"types": "index.d.ts",

src/module/rabbitmq.extension.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ export class RabbitMQExt implements OnExtensionLoad, OnModuleInstantiated, OnShu
7171
debug('bootstrapping module: asserting exchanges, queues, binds, messages routing');
7272

7373
// Try to reconnect and launch bootstrap when we have an error
74-
connection.on('error', () => {
74+
connection.once('error', () => {
75+
debug('connection.once#error: try to reconnect');
7576
connection
7677
.connect()
77-
.flatMap(() => RegisterAnnotations.bootstrap(module, connection, RabbitMQExt.MessageRouter))
78+
.do(() => this.onModuleInstantiated(module, connection))
7879
.subscribe(() => {}, err => {
7980
errorHandler(err);
8081
});
@@ -97,5 +98,3 @@ export class RabbitMQExt implements OnExtensionLoad, OnModuleInstantiated, OnShu
9798
};
9899
}
99100
}
100-
101-

0 commit comments

Comments
 (0)