Skip to content

Commit

Permalink
Merge 94a64db into 66f7db8
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinegomez committed Sep 28, 2018
2 parents 66f7db8 + 94a64db commit 0b70451
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -453,6 +453,8 @@ To set up your development environment:
[Back to top](#table-of-contents)

## Change History
* v1.5.1 (2018-09-24)
* Fix reconnection error: use once instad of on and rebind event correctly
* v1.5.0 (2018-08-24)
* Add possibility to provide a custom MessageRouter
* v1.4.3 (2018-08-20)
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@hapiness/rabbitmq",
"version": "1.5.0",
"version": "1.5.1",
"description": "Hapiness module for rabbitmq",
"main": "commonjs/index.js",
"types": "index.d.ts",
Expand Down
11 changes: 7 additions & 4 deletions src/module/rabbitmq.extension.ts
Expand Up @@ -71,12 +71,17 @@ export class RabbitMQExt implements OnExtensionLoad, OnModuleInstantiated, OnShu
debug('bootstrapping module: asserting exchanges, queues, binds, messages routing');

// Try to reconnect and launch bootstrap when we have an error
connection.on('error', () => {
connection.once('error', () => {
debug('connection.once#error: try to reconnect');
connection
.connect()
.flatMap(() => RegisterAnnotations.bootstrap(module, connection, RabbitMQExt.MessageRouter))
.do(() => this.onModuleInstantiated(module, connection))
.subscribe(() => {}, err => {
errorHandler(err);
const connectionError: any = new Error('Connection error');
connectionError.source = err;
connectionError.key = 'HAPINESS_RABBITMQ_CONNECTION_ERROR';
connection.emit('error', connectionError);
});
});

Expand All @@ -97,5 +102,3 @@ export class RabbitMQExt implements OnExtensionLoad, OnModuleInstantiated, OnShu
};
}
}


0 comments on commit 0b70451

Please sign in to comment.