public class AMQStateManager extends Object implements AMQMethodListener
For each AMQProtocolHandler
there is a separate state manager.
The AMQStateManager is now attached to the AMQProtocolHandler
and that is the sole point of reference so that
As the AMQProtocolSession
changes due to failover the AMQStateManager need not be copied around.
The StateManager works by any component can wait for a state change to occur by using the following sequence.
The two step process is required as there is an inherit race condition between starting a process that will cause the state to change and then attempting to wait for that change. The interest in the change must be first set up so that any asynchronous errors that occur can be delivered to the correct waiters.
Modifier | Constructor and Description |
---|---|
|
AMQStateManager() |
|
AMQStateManager(AMQProtocolSession protocolSession) |
protected |
AMQStateManager(AMQState state,
AMQProtocolSession protocolSession) |
Modifier and Type | Method and Description |
---|---|
void |
changeState(AMQState newState) |
void |
clearLastException() |
StateWaiter |
createWaiter(Set<AMQState> states)
Create and add a new waiter to the notification list.
|
void |
error(Exception error)
Propagate error to waiters
|
AMQState |
getCurrentState() |
Exception |
getLastException() |
long |
getWaitTimeout()
This provides a single place that the maximum time for state change to occur can be accessed.
|
<B extends AMQMethodBody> |
methodReceived(AMQMethodEvent<B> evt)
Notifies the listener that an AMQP method event has occurred.
|
void |
removeWaiter(StateWaiter waiter)
Remove the waiter from the notification list.
|
void |
setProtocolSession(AMQProtocolSession session)
Setting of the ProtocolSession will be required when Failover has been successfully completed.
|
public AMQStateManager()
public AMQStateManager(AMQProtocolSession protocolSession)
protected AMQStateManager(AMQState state, AMQProtocolSession protocolSession)
public AMQState getCurrentState()
public void changeState(AMQState newState)
public <B extends AMQMethodBody> boolean methodReceived(AMQMethodEvent<B> evt) throws QpidException
AMQMethodListener
methodReceived
in interface AMQMethodListener
evt
- The AMQP method event (contains the method and channel).QpidException
- if an error has occurred. This exception may be delivered to all registered listeners using
the error() method (see below) allowing them to perform cleanup if necessary.
TODO Consider narrowing the exception.
public void setProtocolSession(AMQProtocolSession session)
AMQProtocolSession
that has been re-established needs to be provided as that is now the
connection to the network.session
- The new protocol sessionpublic void error(Exception error)
error
in interface AMQMethodListener
error
- The error to propagate.public long getWaitTimeout()
public StateWaiter createWaiter(Set<AMQState> states)
states
- The waiter will attempt to wait for one of these desired set states to be achived.public void removeWaiter(StateWaiter waiter)
waiter
- The waiter to remove.public Exception getLastException()
public void clearLastException()
Copyright © 2006–2016 The Apache Software Foundation. All rights reserved.