org.apache.activemq.transport.failover
Class FailoverTransport

java.lang.Object
  extended by org.apache.activemq.transport.failover.FailoverTransport
All Implemented Interfaces:
Service, CompositeTransport, Transport

public class FailoverTransport
extends java.lang.Object
implements CompositeTransport

A Transport that is made reliable by being able to fail over to another transport when a transport failure is detected.

Version:
$Revision$

Constructor Summary
FailoverTransport()
           
 
Method Summary
 void add(java.lang.String u)
           
 void add(java.net.URI[] u)
           
 FutureResponse asyncRequest(java.lang.Object command, ResponseCallback responseCallback)
          An asynchronous request response where the Receipt will be returned in the future.
 Transport getConnectedTransport()
           
 java.net.URI getConnectedTransportURI()
           
 long getInitialReconnectDelay()
           
 int getMaxReconnectAttempts()
           
 long getMaxReconnectDelay()
           
 long getReconnectDelay()
           
 long getReconnectDelayExponent()
           
 java.lang.String getRemoteAddress()
           
 TransportListener getTransportListener()
          Returns the current transport listener
 boolean isRandomize()
           
 boolean isUseExponentialBackOff()
           
 java.lang.Object narrow(java.lang.Class target)
           
 void oneway(java.lang.Object o)
          A one way asynchronous send
 void reconnect()
           
 void remove(java.net.URI[] u)
           
 java.lang.Object request(java.lang.Object command)
          A synchronous request response
 java.lang.Object request(java.lang.Object command, int timeout)
          A synchronous request response
protected  void restoreTransport(Transport t)
           
 void setInitialReconnectDelay(long initialReconnectDelay)
           
 void setMaxReconnectAttempts(int maxReconnectAttempts)
           
 void setMaxReconnectDelay(long maxReconnectDelay)
           
 void setRandomize(boolean randomize)
           
 void setReconnectDelay(long reconnectDelay)
           
 void setReconnectDelayExponent(long reconnectDelayExponent)
           
 void setTransportListener(TransportListener commandListener)
          Registers an inbound command listener
 void setUseExponentialBackOff(boolean useExponentialBackOff)
           
 void start()
           
 void stop()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FailoverTransport

public FailoverTransport()
                  throws java.io.InterruptedIOException
Throws:
java.io.InterruptedIOException
Method Detail

start

public void start()
           throws java.lang.Exception
Specified by:
start in interface Service
Throws:
java.lang.Exception

stop

public void stop()
          throws java.lang.Exception
Specified by:
stop in interface Service
Throws:
java.lang.Exception

getInitialReconnectDelay

public long getInitialReconnectDelay()

setInitialReconnectDelay

public void setInitialReconnectDelay(long initialReconnectDelay)

getMaxReconnectDelay

public long getMaxReconnectDelay()

setMaxReconnectDelay

public void setMaxReconnectDelay(long maxReconnectDelay)

getReconnectDelay

public long getReconnectDelay()

setReconnectDelay

public void setReconnectDelay(long reconnectDelay)

getReconnectDelayExponent

public long getReconnectDelayExponent()

setReconnectDelayExponent

public void setReconnectDelayExponent(long reconnectDelayExponent)

getConnectedTransport

public Transport getConnectedTransport()

getConnectedTransportURI

public java.net.URI getConnectedTransportURI()

getMaxReconnectAttempts

public int getMaxReconnectAttempts()

setMaxReconnectAttempts

public void setMaxReconnectAttempts(int maxReconnectAttempts)

isRandomize

public boolean isRandomize()
Returns:
Returns the randomize.

setRandomize

public void setRandomize(boolean randomize)
Parameters:
randomize - The randomize to set.

oneway

public void oneway(java.lang.Object o)
            throws java.io.IOException
Description copied from interface: Transport
A one way asynchronous send

Specified by:
oneway in interface Transport
Throws:
java.io.IOException

asyncRequest

public FutureResponse asyncRequest(java.lang.Object command,
                                   ResponseCallback responseCallback)
                            throws java.io.IOException
Description copied from interface: Transport
An asynchronous request response where the Receipt will be returned in the future. If responseCallback is not null, then it will be called when the response has been completed.

Specified by:
asyncRequest in interface Transport
responseCallback - TODO
Returns:
the FutureResponse
Throws:
java.io.IOException

request

public java.lang.Object request(java.lang.Object command)
                         throws java.io.IOException
Description copied from interface: Transport
A synchronous request response

Specified by:
request in interface Transport
Returns:
the response
Throws:
java.io.IOException

request

public java.lang.Object request(java.lang.Object command,
                                int timeout)
                         throws java.io.IOException
Description copied from interface: Transport
A synchronous request response

Specified by:
request in interface Transport
Returns:
the repsonse or null if timeout
Throws:
java.io.IOException

add

public void add(java.net.URI[] u)
Specified by:
add in interface CompositeTransport

remove

public void remove(java.net.URI[] u)
Specified by:
remove in interface CompositeTransport

add

public void add(java.lang.String u)

reconnect

public void reconnect()

getTransportListener

public TransportListener getTransportListener()
Description copied from interface: Transport
Returns the current transport listener

Specified by:
getTransportListener in interface Transport
Returns:

setTransportListener

public void setTransportListener(TransportListener commandListener)
Description copied from interface: Transport
Registers an inbound command listener

Specified by:
setTransportListener in interface Transport

narrow

public java.lang.Object narrow(java.lang.Class target)
Specified by:
narrow in interface Transport
Returns:
the target

restoreTransport

protected void restoreTransport(Transport t)
                         throws java.lang.Exception,
                                java.io.IOException
Throws:
java.lang.Exception
java.io.IOException

isUseExponentialBackOff

public boolean isUseExponentialBackOff()

setUseExponentialBackOff

public void setUseExponentialBackOff(boolean useExponentialBackOff)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getRemoteAddress

public java.lang.String getRemoteAddress()
Specified by:
getRemoteAddress in interface Transport
Returns:
the remote address for this connection


Copyright © 2009 Apache Software Foundation. All Rights Reserved.