Skip to content

Commit f7d188f

Browse files
authored
feat: add heartbeat (#20)
1 parent 8dca5c8 commit f7d188f

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

lib/service_amqp.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ module.exports = class Amqp extends Component.mixin(AsyncEmitter) {
2727
*doConnect() {
2828
if (this._initializing) return;
2929
this._initializing = true;
30-
let { secure, user, password, host, port, connectionString } = this.config.default("service.rabbit", { host: "localhost", port: 5672 });
30+
let { secure, user, password, host, port, connectionString, heartbeat } = this.config.default("service.rabbit", { host: "localhost", port: 5672, heartbeat: 20 });
3131

3232
let protocol = (typeof secure === "boolean" && secure) ? "amqps" : "amqp";
3333

@@ -41,9 +41,11 @@ module.exports = class Amqp extends Component.mixin(AsyncEmitter) {
4141
connectionString = `${protocol}://${host}:${port}`;
4242
}
4343
}
44+
45+
let connectionStringOpts = `${connectionString}?heartbeat=${heartbeat}`;
4446

4547
try {
46-
this._connection = yield amqp.connect(connectionString);
48+
this._connection = yield amqp.connect(connectionStringOpts);
4749

4850
this.logger.info("Connected to rmq.");
4951

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "merapi-plugin-service-rabbit",
3-
"version": "0.5.2",
3+
"version": "0.6.1",
44
"description": "Provide RabbitMQ integration interface",
55
"main": "index.js",
66
"scripts": {
@@ -41,4 +41,4 @@
4141
"nyc": "^13.3.0",
4242
"supertest": "^3.3.0"
4343
}
44-
}
44+
}

0 commit comments

Comments
 (0)