Skip to content
This repository has been archived by the owner on Jun 14, 2019. It is now read-only.

Commit

Permalink
Merge branch 'feature/vertx_eventbus_3.5.x' into canary
Browse files Browse the repository at this point in the history
  • Loading branch information
knalli committed Feb 17, 2018
2 parents ddf357a + 229a29b commit d5ca56d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"dependencies": {
"angular": ">=1.2 <1.7",
"sockjs-client": "~1.1.0",
"vertx3-eventbus-client": "~3.4.0"
"vertx3-eventbus-client": "~3.5.0"
},
"devDependencies": {
"angular": "~1.6.2",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"test-scopes": "grunt install-test && for f in test_scopes/*; do TEST_SCOPE=\"`basename $f`\" npm run -s test; done",
"start-it-web-server": "babel-node test/e2e/server.js",
"install-it-vertx-server": "cd test/e2e/vertx && ./install-vertx.sh",
"start-it-vertx-server": "cd test/e2e/vertx/app && ../runtime/bin/vertx run vertx3-config.js",
"start-it-vertx-server": "cd test/e2e/vertx/app && ../runtime/vertx/bin/vertx run vertx3-config.js",
"start-server": "npm-run-all --silent clean compile-dist install-it-vertx-server --parallel start-it-vertx-server start-it-web-server",
"compile-dist": "webpack",
"compile-distmin": "BUILD_MINIFIED=1 webpack",
Expand Down
12 changes: 12 additions & 0 deletions src/lib/adapter/EventBusAdapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ export default class EventBusAdapter extends BaseAdapter {
sockjsReconnectInterval,
sockjsOptions
};
this.nativeReconnectAvailable = false,
this.disconnectTimeoutEnabled = true;
this.applyDefaultHeaders();
if (initialConnectEnabled) {
Expand Down Expand Up @@ -157,6 +158,11 @@ export default class EventBusAdapter extends BaseAdapter {
// Because we have rebuild an EventBus object (because it have to rebuild a SockJS object)
// we must wrap the object. Therefore, we have to mimic the behavior of onopen and onclose each time.
this.instance = new this.EventBus(url, this.options.sockjsOptions);
// Since vertx-eventbus 3.5.0 support for "native" reconnect is available
this.nativeReconnectAvailable = typeof this.instance.enableReconnect === 'function';
if (this.nativeReconnectAvailable && this.options.reconnectEnabled) {
this.instance.enableReconnect(true);
}
this.instance.onopen = () => {
if (this.options.debugEnabled) {
this.$log.debug('[Vert.x EB Stub] Connected');
Expand All @@ -168,6 +174,12 @@ export default class EventBusAdapter extends BaseAdapter {
};
// instance onClose handler
this.instance.onclose = () => {
// Since [email protected], the EventBus itself can handle reconnects
if (this.nativeReconnectAvailable && this.instance.reconnectTimerID) {
// 'reconnectTimerID' will be only set if reconnect is enabled
this.$log.debug('[Vert.x EB Stub] Reconnect required, but seems to be handled by EventBus itself');
return;
}
if (this.options.debugEnabled) {
this.$log.debug(`[Vert.x EB Stub] Reconnect in ${this.options.sockjsReconnectInterval}ms`);
}
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/vertx/install-vertx.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
ARCHIVE="vert.x-3.2.0-full.tar.gz"
ARCHIVE="vert.x-3.5.1-full.tar.gz"
DIRECTORY="runtime"
[ -e ${ARCHIVE} ] || wget https://bintray.com/artifact/download/vertx/downloads/${ARCHIVE}
if [ ! -e ${DIRECTORY} ]; then
Expand Down

0 comments on commit d5ca56d

Please sign in to comment.