This repository has been archived by the owner on Jun 14, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/vertx_eventbus_3.5.x' into canary
- Loading branch information
Showing
4 changed files
with
15 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -121,6 +121,7 @@ export default class EventBusAdapter extends BaseAdapter { | |
sockjsReconnectInterval, | ||
sockjsOptions | ||
}; | ||
this.nativeReconnectAvailable = false, | ||
this.disconnectTimeoutEnabled = true; | ||
this.applyDefaultHeaders(); | ||
if (initialConnectEnabled) { | ||
|
@@ -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'); | ||
|
@@ -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`); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters