public class FailoverHandler extends Object implements Runnable
AMQProtocolHandler, a protocol connection can span many physical transport
connections, failing over to a new connection if the transport connection fails. The procedure to establish a new
connection is expressed as a continuation, in order that it may be run in a seperate thread to the i/o thread that
detected the failure and is used to handle the communication to establish a new connection.
The reason this needs to be a separate thread is because this work cannot be done inside the i/o processor thread. The significant task is the connection setup which involves a protocol exchange until a particular state is achieved. This procedure waits until the state is achieved which would prevent the i/o thread doing the work it needs to do to achieve the new state.
The failover procedure does the following:
FailoverException and gets the protocol connection handler to propagate this event to all
interested parties.AMQStateManager and re-established the connection through it.TODO The failover latch and mutex are used like a lock and condition. If the retrotranlator supports lock/condition then could change over to using them. 1.4 support still needed.
TODO If the condition is set to null on a vetoes fail-over and there are already other threads waiting on the condition, they will never be released. It might be an idea to reset the condition in a finally block.
TODO Creates a AMQDisconnectedException and passes it to the AMQConnection. No need to use an
exception-as-argument here, could just as easily call a specific method for this purpose on AMQConnection.
TODO Creates a FailoverException and propagates it to the MethodHandlers. No need to use an
exception-as-argument here, could just as easily call a specific method for this purpose on
AMQMethodListener.
| Constructor and Description |
|---|
FailoverHandler(AMQProtocolHandler amqProtocolHandler)
Creates a failover handler on a protocol session, for a particular MINA session (network connection).
|
public FailoverHandler(AMQProtocolHandler amqProtocolHandler)
amqProtocolHandler - The protocol handler that spans the failover.public void run()
FailoverHandler, for a description of the
failover procedure.public void setHost(String host)
host - The host name to fail over to.public void setPort(int port)
port - The port to fail over to.Copyright © 2006–2014 The Apache Software Foundation. All rights reserved.