You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jun 18, 2024. It is now read-only.
StreamingSubscriptionConnection.getIsOpen() returns true initially, but then starts returning false after the OnDisconnect handler fires (calling StreamingSubscriptionConnection.open())
After the time-out of the connection has elapsed, the OnDisconnect event is raised by the StreamingSubscriptionConnection instance. If your application still needs to monitor the subscription, you can just call the Open method of the StreamingSubscriptionConnection instance again to reconnect to the Exchange server. This behavior is expected and is not an error condition.
Please see my code below with comments showing when connection.getIsOpen() initially returns true, but starts returning false after the disconnect handler fires
publicclassEwsClient {
privatefinalExchangeServiceexchangeService;
privatefinalSet<StreamingSubscriptionConnection> subscriptionConnections = ConcurrentHashMap.newKeySet();
privatefinalintsubscriptionLifetimeMinutes = 2;
// constructorpublicvoidsubscribe(Collection<FolderId> folderIds, EventType[] eventTypes, INotificationEventDelegateeventHandler) throwsException {
StreamingSubscriptionsubscription = exchangeService.subscribeToStreamingNotifications(folderIds, eventTypes);
StreamingSubscriptionConnectionconnection = newStreamingSubscriptionConnection(exchangeService, subscriptionLifetimeMinutes), eventHandler);
ISubscriptionErrorDelegatedisconnectHandler = (sender, args) -> {
try {
connection.open(); // connection.getIsOpen() will start returning false now
} catch (Exceptione) {
// I would expect connection.getIsOpen() will start returning false nowlog.error("Could not reconnect to the exchange server", e);
}
};
connection.addSubscription(subscription);
connection.addOnNotificationEvent(eventHandler);
connection.addOnDisconnect(disconnectHandler);
subscriptionConnections.add(connection);
connection.open(); // connection.getIsOpen() will return true initially
}
// I use this method in a spring boot health checkpublicbooleanisSubscriptionsOpen() {
returnsubscriptionConnections.stream().allMatch(connection -> {
try {
returnconnection.getIsOpen();
} catch (Exceptione) {
log.error("Error validating subscription connection", e);
returnfalse;
}
});
}
}
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
StreamingSubscriptionConnection.getIsOpen() returns true initially, but then starts returning false after the OnDisconnect handler fires (calling StreamingSubscriptionConnection.open())
The documentation here states:
Please see my code below with comments showing when connection.getIsOpen() initially returns true, but starts returning false after the disconnect handler fires
The text was updated successfully, but these errors were encountered: