activemq-cpp-3.6.0
activemq::transport::failover::FailoverTransport Class Reference

#include <src/main/activemq/transport/failover/FailoverTransport.h>

Inheritance diagram for activemq::transport::failover::FailoverTransport:

Public Member Functions

 FailoverTransport ()
virtual ~FailoverTransport ()
void reconnect (bool rebalance)
 Indicates that the Transport needs to reconnect to another URI in its list.
void add (bool rebalance, const std::string &uri)
 Adds a New URI to the List of URIs this transport can Connect to.
virtual void addURI (bool rebalance, const List< decaf::net::URI > &uris)
 Add a URI to the list of URI's that will represent the set of Transports that this Transport is a composite of.
virtual void removeURI (bool rebalance, const List< decaf::net::URI > &uris)
 Remove a URI from the set of URI's that represents the set of Transports that this Transport is composed of, removing a URI for which the composite has created a connected Transport should result in that Transport being disposed of.
virtual void start ()
 Starts the Transport, the send methods of a Transport will throw an exception if used before the Transport is started.
virtual void stop ()
 Stops the Transport.
virtual void close ()
 Closes this object and deallocates the appropriate resources.
virtual void oneway (const Pointer< Command > command)
 Sends a one-way command.
virtual Pointer< FutureResponseasyncRequest (const Pointer< Command > command, const Pointer< ResponseCallback > responseCallback)
 Sends a commands asynchronously, returning a FutureResponse object that the caller can use to check to find out the response from the broker.
virtual Pointer< Responserequest (const Pointer< Command > command)
 Sends the given command to the broker and then waits for the response.
virtual Pointer< Responserequest (const Pointer< Command > command, unsigned int timeout)
 Sends the given command to the broker and then waits for the response.
virtual Pointer
< wireformat::WireFormat
getWireFormat () const
 Gets the WireFormat instance that is in use by this transport.
virtual void setWireFormat (const Pointer< wireformat::WireFormat > wireFormat AMQCPP_UNUSED)
 Sets the WireFormat instance to use.
virtual void setTransportListener (TransportListener *listener)
 Sets the observer of asynchronous events from this transport.
virtual TransportListenergetTransportListener () const
 Gets the observer of asynchronous events from this transport.
virtual bool isFaultTolerant () const
 Is this Transport fault tolerant, meaning that it will reconnect to a broker on disconnect.
virtual bool isConnected () const
 Is the Transport Connected to its Broker.
virtual bool isClosed () const
 Has the Transport been shutdown and no longer usable.
bool isInitialized () const
void setInitialized (bool value)
virtual Transportnarrow (const std::type_info &typeId)
 Narrows down a Chain of Transports to a specific Transport to allow a higher level transport to skip intermediate Transports in certain circumstances.
virtual std::string getRemoteAddress () const
virtual void reconnect (const decaf::net::URI &uri)
 reconnect to another location
virtual void updateURIs (bool rebalance, const decaf::util::List< decaf::net::URI > &uris)
 Updates the set of URIs the Transport can connect to.
virtual bool isPending () const
virtual bool iterate ()
 Performs the actual Reconnect operation for the FailoverTransport, when a connection is made this method returns false to indicate it doesn't need to run again, otherwise it returns true to indicate its still trying to connect.
long long getTimeout () const
void setTimeout (long long value)
long long getInitialReconnectDelay () const
void setInitialReconnectDelay (long long value)
long long getMaxReconnectDelay () const
void setMaxReconnectDelay (long long value)
long long getBackOffMultiplier () const
void setBackOffMultiplier (long long value)
bool isUseExponentialBackOff () const
void setUseExponentialBackOff (bool value)
bool isRandomize () const
void setRandomize (bool value)
int getMaxReconnectAttempts () const
void setMaxReconnectAttempts (int value)
int getStartupMaxReconnectAttempts () const
void setStartupMaxReconnectAttempts (int value)
long long getReconnectDelay () const
void setReconnectDelay (long long value)
bool isBackup () const
void setBackup (bool value)
int getBackupPoolSize () const
void setBackupPoolSize (int value)
bool isTrackMessages () const
void setTrackMessages (bool value)
bool isTrackTransactionProducers () const
void setTrackTransactionProducers (bool value)
int getMaxCacheSize () const
void setMaxCacheSize (int value)
bool isReconnectSupported () const
void setReconnectSupported (bool value)
bool isUpdateURIsSupported () const
void setUpdateURIsSupported (bool value)
bool isRebalanceUpdateURIs () const
void setRebalanceUpdateURIs (bool rebalanceUpdateURIs)
bool isPriorityBackup () const
void setPriorityBackup (bool priorityBackup)
void setPriorityURIs (const std::string &priorityURIs)
const decaf::util::List
< decaf::net::URI > & 
getPriorityURIs () const
void setConnectionInterruptProcessingComplete (const Pointer< commands::ConnectionId > connectionId)
bool isConnectedToPriority () const
- Public Member Functions inherited from activemq::transport::CompositeTransport
virtual ~CompositeTransport ()
- Public Member Functions inherited from activemq::transport::Transport
virtual ~Transport ()
- Public Member Functions inherited from decaf::io::Closeable
virtual ~Closeable ()
- Public Member Functions inherited from activemq::threads::CompositeTask
virtual ~CompositeTask ()
- Public Member Functions inherited from activemq::threads::Task
virtual ~Task ()

Protected Member Functions

void restoreTransport (const Pointer< Transport > transport)
 Given a Transport restore the state of the Client's connection to the Broker using the data accumulated in the State Tracker.
void handleTransportFailure (const decaf::lang::Exception &error)
 Called when this class' TransportListener is notified of a Failure.
void handleConnectionControl (const Pointer< Command > control)
 Called when the Broker sends a ConnectionControl command which could signal that this Client needs to reconnect in order to rebalance the connections on a Broker or the set of Known brokers has changed.

Friends

class FailoverTransportListener
class BackupTransportPool

Constructor & Destructor Documentation

activemq::transport::failover::FailoverTransport::FailoverTransport ( )
virtual activemq::transport::failover::FailoverTransport::~FailoverTransport ( )
virtual

Member Function Documentation

void activemq::transport::failover::FailoverTransport::add ( bool  rebalance,
const std::string &  uri 
)

Adds a New URI to the List of URIs this transport can Connect to.

Parameters
rebalanceShould the transport reconnect to a different broker to balance load.
uriA String version of a URI to add to the URIs to failover to.
virtual void activemq::transport::failover::FailoverTransport::addURI ( bool  rebalance,
const List< decaf::net::URI > &  uris 
)
virtual

Add a URI to the list of URI's that will represent the set of Transports that this Transport is a composite of.

Parameters
rebalanceIndicates if the addition should cause a forced reconnect or not.
urisThe new URI set to add to the set this composite maintains.

Implements activemq::transport::CompositeTransport.

virtual Pointer<FutureResponse> activemq::transport::failover::FailoverTransport::asyncRequest ( const Pointer< Command command,
const Pointer< ResponseCallback responseCallback 
)
virtual

Sends a commands asynchronously, returning a FutureResponse object that the caller can use to check to find out the response from the broker.

Parameters
commandThe Command object that is to sent out.
responseCallbackA callback object that will be notified once a response to the command is received.
Returns
A FutureResponse instance that can be queried for the Response to the Command.
Exceptions
IOExceptionif an exception occurs during the read of the command.
UnsupportedOperationExceptionif this method is not implemented by this transport.

Implements activemq::transport::Transport.

virtual void activemq::transport::failover::FailoverTransport::close ( )
virtual

Closes this object and deallocates the appropriate resources.

The object is generally no longer usable after calling close.

Exceptions
IOExceptionif an error occurs while closing.

Implements decaf::io::Closeable.

long long activemq::transport::failover::FailoverTransport::getBackOffMultiplier ( ) const
int activemq::transport::failover::FailoverTransport::getBackupPoolSize ( ) const
long long activemq::transport::failover::FailoverTransport::getInitialReconnectDelay ( ) const
int activemq::transport::failover::FailoverTransport::getMaxCacheSize ( ) const
int activemq::transport::failover::FailoverTransport::getMaxReconnectAttempts ( ) const
long long activemq::transport::failover::FailoverTransport::getMaxReconnectDelay ( ) const
const decaf::util::List<decaf::net::URI>& activemq::transport::failover::FailoverTransport::getPriorityURIs ( ) const
long long activemq::transport::failover::FailoverTransport::getReconnectDelay ( ) const
virtual std::string activemq::transport::failover::FailoverTransport::getRemoteAddress ( ) const
virtual
Returns
the remote address for this connection

Implements activemq::transport::Transport.

int activemq::transport::failover::FailoverTransport::getStartupMaxReconnectAttempts ( ) const
long long activemq::transport::failover::FailoverTransport::getTimeout ( ) const
virtual TransportListener* activemq::transport::failover::FailoverTransport::getTransportListener ( ) const
virtual

Gets the observer of asynchronous events from this transport.

Returns
the listener of transport events.

Implements activemq::transport::Transport.

virtual Pointer<wireformat::WireFormat> activemq::transport::failover::FailoverTransport::getWireFormat ( ) const
virtual

Gets the WireFormat instance that is in use by this transport.

In the case of nested transport this method delegates down to the lowest level transport that actually maintains a WireFormat info instance.

Returns
The WireFormat the object used to encode / decode commands.

Implements activemq::transport::Transport.

void activemq::transport::failover::FailoverTransport::handleConnectionControl ( const Pointer< Command control)
protected

Called when the Broker sends a ConnectionControl command which could signal that this Client needs to reconnect in order to rebalance the connections on a Broker or the set of Known brokers has changed.

Parameters
controlThe ConnectionControl command sent from the Broker.
void activemq::transport::failover::FailoverTransport::handleTransportFailure ( const decaf::lang::Exception error)
protected

Called when this class' TransportListener is notified of a Failure.

Parameters
error- The CMS Exception that was thrown.
Exceptions
Exceptionif an error occurs.
bool activemq::transport::failover::FailoverTransport::isBackup ( ) const
virtual bool activemq::transport::failover::FailoverTransport::isClosed ( ) const
virtual

Has the Transport been shutdown and no longer usable.

Returns
true if the Transport

Implements activemq::transport::Transport.

virtual bool activemq::transport::failover::FailoverTransport::isConnected ( ) const
virtual

Is the Transport Connected to its Broker.

Returns
true if a connection has been made.

Implements activemq::transport::Transport.

bool activemq::transport::failover::FailoverTransport::isConnectedToPriority ( ) const
virtual bool activemq::transport::failover::FailoverTransport::isFaultTolerant ( ) const
inlinevirtual

Is this Transport fault tolerant, meaning that it will reconnect to a broker on disconnect.

Returns
true if the Transport is fault tolerant.

Implements activemq::transport::Transport.

bool activemq::transport::failover::FailoverTransport::isInitialized ( ) const
virtual bool activemq::transport::failover::FailoverTransport::isPending ( ) const
virtual
Returns
true if there is a need for the iterate method to be called by this classes task runner.

Implements activemq::threads::CompositeTask.

bool activemq::transport::failover::FailoverTransport::isPriorityBackup ( ) const
bool activemq::transport::failover::FailoverTransport::isRandomize ( ) const
bool activemq::transport::failover::FailoverTransport::isRebalanceUpdateURIs ( ) const
bool activemq::transport::failover::FailoverTransport::isReconnectSupported ( ) const
virtual
Returns
true if reconnect is supported.

Implements activemq::transport::Transport.

bool activemq::transport::failover::FailoverTransport::isTrackMessages ( ) const
bool activemq::transport::failover::FailoverTransport::isTrackTransactionProducers ( ) const
bool activemq::transport::failover::FailoverTransport::isUpdateURIsSupported ( ) const
virtual
Returns
true if updating uris is supported.

Implements activemq::transport::Transport.

bool activemq::transport::failover::FailoverTransport::isUseExponentialBackOff ( ) const
virtual bool activemq::transport::failover::FailoverTransport::iterate ( )
virtual

Performs the actual Reconnect operation for the FailoverTransport, when a connection is made this method returns false to indicate it doesn't need to run again, otherwise it returns true to indicate its still trying to connect.

Returns
false to indicate a connection, true to indicate it needs to try again.

Implements activemq::threads::Task.

virtual Transport* activemq::transport::failover::FailoverTransport::narrow ( const std::type_info &  typeId)
virtual

Narrows down a Chain of Transports to a specific Transport to allow a higher level transport to skip intermediate Transports in certain circumstances.

Parameters
typeId- The type_info of the Object we are searching for.
Returns
the requested Object. or NULL if its not in this chain.

Implements activemq::transport::Transport.

virtual void activemq::transport::failover::FailoverTransport::oneway ( const Pointer< Command command)
virtual

Sends a one-way command.

Does not wait for any response from the broker.

Parameters
commandThe command to be sent.
Exceptions
IOExceptionif an exception occurs during writing of the command.
UnsupportedOperationExceptionif this method is not implemented by this transport.

Implements activemq::transport::Transport.

void activemq::transport::failover::FailoverTransport::reconnect ( bool  rebalance)

Indicates that the Transport needs to reconnect to another URI in its list.

Parameters
rebalanceIndicates if the current connection should be broken and reconnected.
virtual void activemq::transport::failover::FailoverTransport::reconnect ( const decaf::net::URI uri)
virtual

reconnect to another location

Parameters
uriThe new URI to connect this Transport to.
Exceptions
IOExceptionon failure or if reconnect is not supported.

Implements activemq::transport::Transport.

virtual void activemq::transport::failover::FailoverTransport::removeURI ( bool  rebalance,
const List< decaf::net::URI > &  uris 
)
virtual

Remove a URI from the set of URI's that represents the set of Transports that this Transport is composed of, removing a URI for which the composite has created a connected Transport should result in that Transport being disposed of.

Parameters
rebalanceIndicates if the removal should cause a forced reconnect or not.
urisThe new URI set to remove to the set this composite maintains.

Implements activemq::transport::CompositeTransport.

virtual Pointer<Response> activemq::transport::failover::FailoverTransport::request ( const Pointer< Command command)
virtual

Sends the given command to the broker and then waits for the response.

Parameters
commandthe command to be sent.
Returns
the response from the broker.
Exceptions
IOExceptionif an exception occurs during the read of the command.
UnsupportedOperationExceptionif this method is not implemented by this transport.

Implements activemq::transport::Transport.

virtual Pointer<Response> activemq::transport::failover::FailoverTransport::request ( const Pointer< Command command,
unsigned int  timeout 
)
virtual

Sends the given command to the broker and then waits for the response.

Parameters
commandThe command to be sent.
timeoutThe time to wait for this response.
Returns
the response from the broker.
Exceptions
IOExceptionif an exception occurs during the read of the command.
UnsupportedOperationExceptionif this method is not implemented by this transport.

Implements activemq::transport::Transport.

void activemq::transport::failover::FailoverTransport::restoreTransport ( const Pointer< Transport transport)
protected

Given a Transport restore the state of the Client's connection to the Broker using the data accumulated in the State Tracker.

Parameters
transportThe new Transport connected to the Broker.
Exceptions
IOExceptionif an errors occurs while restoring the old state.
void activemq::transport::failover::FailoverTransport::setBackOffMultiplier ( long long  value)
void activemq::transport::failover::FailoverTransport::setBackup ( bool  value)
void activemq::transport::failover::FailoverTransport::setBackupPoolSize ( int  value)
void activemq::transport::failover::FailoverTransport::setConnectionInterruptProcessingComplete ( const Pointer< commands::ConnectionId connectionId)
void activemq::transport::failover::FailoverTransport::setInitialized ( bool  value)
void activemq::transport::failover::FailoverTransport::setInitialReconnectDelay ( long long  value)
void activemq::transport::failover::FailoverTransport::setMaxCacheSize ( int  value)
void activemq::transport::failover::FailoverTransport::setMaxReconnectAttempts ( int  value)
void activemq::transport::failover::FailoverTransport::setMaxReconnectDelay ( long long  value)
void activemq::transport::failover::FailoverTransport::setPriorityBackup ( bool  priorityBackup)
void activemq::transport::failover::FailoverTransport::setPriorityURIs ( const std::string &  priorityURIs)
void activemq::transport::failover::FailoverTransport::setRandomize ( bool  value)
void activemq::transport::failover::FailoverTransport::setRebalanceUpdateURIs ( bool  rebalanceUpdateURIs)
void activemq::transport::failover::FailoverTransport::setReconnectDelay ( long long  value)
void activemq::transport::failover::FailoverTransport::setReconnectSupported ( bool  value)
void activemq::transport::failover::FailoverTransport::setStartupMaxReconnectAttempts ( int  value)
void activemq::transport::failover::FailoverTransport::setTimeout ( long long  value)
void activemq::transport::failover::FailoverTransport::setTrackMessages ( bool  value)
void activemq::transport::failover::FailoverTransport::setTrackTransactionProducers ( bool  value)
virtual void activemq::transport::failover::FailoverTransport::setTransportListener ( TransportListener listener)
virtual

Sets the observer of asynchronous events from this transport.

Parameters
listenerthe listener of transport events.

Implements activemq::transport::Transport.

void activemq::transport::failover::FailoverTransport::setUpdateURIsSupported ( bool  value)
void activemq::transport::failover::FailoverTransport::setUseExponentialBackOff ( bool  value)
virtual void activemq::transport::failover::FailoverTransport::setWireFormat ( const Pointer< wireformat::WireFormat > wireFormat  wireFormat)
inlinevirtual

Sets the WireFormat instance to use.

Parameters
wireFormatThe WireFormat the object used to encode / decode commands.

Implements activemq::transport::Transport.

virtual void activemq::transport::failover::FailoverTransport::start ( )
virtual

Starts the Transport, the send methods of a Transport will throw an exception if used before the Transport is started.

Exceptions
IOExceptionif and error occurs while starting the Transport.

Implements activemq::transport::Transport.

virtual void activemq::transport::failover::FailoverTransport::stop ( )
virtual

Stops the Transport.

Exceptions
IOExceptionif an error occurs while stopping the transport.

Implements activemq::transport::Transport.

virtual void activemq::transport::failover::FailoverTransport::updateURIs ( bool  rebalance,
const decaf::util::List< decaf::net::URI > &  uris 
)
virtual

Updates the set of URIs the Transport can connect to.

If the Transport doesn't support updating its URIs then an IOException is thrown.

Parameters
rebalanceIndicates if a forced reconnection should be performed as a result of the update.
urisThe new list of URIs that can be used for connection.
Exceptions
IOExceptionif an error occurs or updates aren't supported.

Implements activemq::transport::Transport.

Friends And Related Function Documentation

friend class BackupTransportPool
friend
friend class FailoverTransportListener
friend

The documentation for this class was generated from the following file: