Skip to content

Commit b18b06e

Browse files
authored
Merge pull request #41 from hapinessjs/next
Next
2 parents 5df2025 + dd6b4bb commit b18b06e

4 files changed

Lines changed: 11 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: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,17 @@ 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);
81+
const connectionError: any = new Error('Connection error');
82+
connectionError.source = err;
83+
connectionError.key = 'HAPINESS_RABBITMQ_CONNECTION_ERROR';
84+
connection.emit('error', connectionError);
8085
});
8186
});
8287

@@ -97,5 +102,3 @@ export class RabbitMQExt implements OnExtensionLoad, OnModuleInstantiated, OnShu
97102
};
98103
}
99104
}
100-
101-

0 commit comments

Comments
 (0)