Class RetryableAmLink
- java.lang.Object
-
- org.forgerock.openig.tools.notifications.ws.link.RetryableAmLink
-
- All Implemented Interfaces:
AmLink
,AmLinkListener
public final class RetryableAmLink extends Object implements AmLink, AmLinkListener
Retry theAmLink
start according to criterion. This class is also responsible for getting the SSO token needed by AM for WebSocket authentication and refreshing it upon authorization failure.- See Also:
AmLink
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
RetryableAmLink.AmLinkSupplierFromToken
-
Nested classes/interfaces inherited from interface org.forgerock.openig.tools.notifications.ws.link.AmLink
AmLink.AmLinkSupplier, AmLink.ResilientAmLinkSupplier
-
Nested classes/interfaces inherited from interface org.forgerock.openig.tools.notifications.ws.link.AmLinkListener
AmLinkListener.ResilientAmLinkListener
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static AmLink.AmLinkSupplier
asInfiniteRetrySupplier(Duration delay, AsyncRefreshableSupplier<SsoToken,AuthenticationException> tokenProvider, RetryableAmLink.AmLinkSupplierFromToken amLinkSupplierFromToken, ScheduledExecutorService executor)
Builds a supplier ofRetryableAmLink
without any retry limit.static AmLink.AmLinkSupplier
asSupplier(boolean stopOnSslFailure, int retryLimit, Duration delay, AsyncRefreshableSupplier<SsoToken,AuthenticationException> tokenProvider, RetryableAmLink.AmLinkSupplierFromToken amLinkSupplierFromToken, ScheduledExecutorService executor)
Builds a supplier ofRetryableAmLink
.Promise<Void,Exception>
close()
Close theAmLink
and its associated resources.void
onDisconnection()
The handler to call in case of a disconnection.void
onNotification(Notification notification)
The notification handler, will receive all notifications sent by AM.Promise<Void,Exception>
start()
Start theAmLink
.Promise<Void,Exception>
subscribe(String topic)
Subscribe to an AM topic.Promise<Void,Exception>
unsubscribe(String topic)
Unsubscribe from an AM topic.
-
-
-
Method Detail
-
close
public Promise<Void,Exception> close()
Description copied from interface:AmLink
Close theAmLink
and its associated resources. The instance can't be reused afterward.
-
subscribe
public Promise<Void,Exception> subscribe(String topic)
Description copied from interface:AmLink
Subscribe to an AM topic. After successful subscription, the notification consumer (supplied in will begin receiving notifications on this topic.
-
unsubscribe
public Promise<Void,Exception> unsubscribe(String topic)
Description copied from interface:AmLink
Unsubscribe from an AM topic. After successful unsubscribe request, the notification consumer will stop receiving notifications on this topic.- Specified by:
unsubscribe
in interfaceAmLink
- Parameters:
topic
- The AM topic to un-subscribe from.- Returns:
- A promise of a successful un-subscription to the AM topic.
-
onDisconnection
public void onDisconnection()
Description copied from interface:AmLinkListener
The handler to call in case of a disconnection. When this handler is called, the instance is considered as closed. Can only be called after the start promise successful completion, and before every ongoing (un)subscribe promise failure.- Specified by:
onDisconnection
in interfaceAmLinkListener
-
onNotification
public void onNotification(Notification notification)
Description copied from interface:AmLinkListener
The notification handler, will receive all notifications sent by AM. Duplicate notifications may occur.- Specified by:
onNotification
in interfaceAmLinkListener
- Parameters:
notification
- the received notification
-
asSupplier
public static AmLink.AmLinkSupplier asSupplier(boolean stopOnSslFailure, int retryLimit, Duration delay, AsyncRefreshableSupplier<SsoToken,AuthenticationException> tokenProvider, RetryableAmLink.AmLinkSupplierFromToken amLinkSupplierFromToken, ScheduledExecutorService executor)
Builds a supplier ofRetryableAmLink
.- Parameters:
stopOnSslFailure
- Whether the AmLink should retry or not on SSL FailureretryLimit
- The maximum number of retriesdelay
- The delay between retriestokenProvider
- The Token provider to use to refresh tokensamLinkSupplierFromToken
- A supplier of AmLinkSuppliers based on tokenexecutor
- The ExecutorService to use to schedule retries- Returns:
- a supplier of
RetryableAmLink
.
-
asInfiniteRetrySupplier
public static AmLink.AmLinkSupplier asInfiniteRetrySupplier(Duration delay, AsyncRefreshableSupplier<SsoToken,AuthenticationException> tokenProvider, RetryableAmLink.AmLinkSupplierFromToken amLinkSupplierFromToken, ScheduledExecutorService executor)
Builds a supplier ofRetryableAmLink
without any retry limit.- Parameters:
delay
- The delay between retriestokenProvider
- The Token provider to use to refresh tokensamLinkSupplierFromToken
- A supplier of AmLinkSuppliers based on tokenexecutor
- The ExecutorService to use to schedule retries- Returns:
- a supplier of
RetryableAmLink
.
-
-