public class FailoverRetrySupport<T,E extends Exception> extends Object implements FailoverSupport<T,E>
The blocking condition used is that the connection is not currently failing over, and the mutex used is the connection failover mutex, which guards against the fail-over process being run during fail-over vulnerable methods. These are used like a lock and condition variable.
The wrapped operation may throw a FailoverException, this is an exception that can be raised by a
BlockingMethodFrameListener
, in response to it being notified that a
fail-over wants to start whilst it was waiting. Methods that are vulnerable to fail-over are those that are
synchronous, where a failure will prevent them from getting the reply they are waiting for and asynchronous
methods that should not be attempted when a fail-over is in progress.
Wrapping a synchronous method in a FailoverRetrySupport will have the effect that the operation will not be
started during fail-over, but be delayed until any current fail-over has completed. Should a fail-over process want
to start whilst waiting for the synchronous reply, the FailoverRetrySupport will detect this and retry the operation
until it succeeds. Synchronous methods are usually coordinated with a
BlockingMethodFrameListener
which is notified when a fail-over process wants
to start and throws a FailoverException in response to this.
Wrapping an asynchronous method in a FailoverRetrySupport will have the effect that the operation will not be started during fail-over, but be delayed until any current fail-over has completed.
TODO InterruptedException not handled well.
Constructor and Description |
---|
FailoverRetrySupport(FailoverProtectedOperation<T,E> operation,
AMQConnection con)
Creates an automatic retrying fail-over handler for the specified operation.
|
Modifier and Type | Method and Description |
---|---|
T |
execute()
Delays a continuation until the "not failing over" condition is met on the specified connection.
|
public FailoverRetrySupport(FailoverProtectedOperation<T,E> operation, AMQConnection con)
operation
- The fail-over protected operation to wrap in this handler.Copyright © 2006–2016 The Apache Software Foundation. All rights reserved.