public class StateWaiter extends BlockingWaiter<AMQState>
BlockingWaiter
to provide error handing and a waiting mechanism for state
changes.
On construction the current state and a set of States to await for is provided.
When await() is called the state at construction is compared against the awaitStates. If the state at construction is
a desired state then await() returns immediately.
Otherwise it will block for the set timeout for a desired state to be achieved.
The state changes are notified via the process(org.apache.qpid.client.state.AMQState)
method.
Any notified error is handled by the BlockingWaiter and thrown from the BlockingWaiter.block(long)
method.Constructor and Description |
---|
StateWaiter(AMQStateManager stateManager,
AMQState currentState,
Set<AMQState> awaitStates) |
Modifier and Type | Method and Description |
---|---|
AMQState |
await()
Await for the required State to be achieved within the default timeout.
|
AMQState |
await(long timeout)
Await for the required State to be achieved.
|
boolean |
process(AMQState state)
When the state is changed this StateWaiter is notified to process the change.
|
block, close, error, received
public StateWaiter(AMQStateManager stateManager, AMQState currentState, Set<AMQState> awaitStates)
stateManager
- The StateManagercurrentState
- awaitStates
- public boolean process(AMQState state)
process
in class BlockingWaiter<AMQState>
state
- The new state that has been achieved.public AMQState await() throws QpidException
QpidException
- The exception that prevented the required state from being achieved.public AMQState await(long timeout) throws QpidException
It is the responsibility of this class to remove the waiter from the StateManager
timeout
- The time in milliseconds to wait for any of the states to be achieved.QpidException
- The exception that prevented the required state from being achieved.Copyright © 2006–2016 The Apache Software Foundation. All rights reserved.