activemq-cpp-3.6.0
activemq::transport::mock::MockTransport Class Reference

The MockTransport defines a base level Transport class that is intended to be used in place of an a regular protocol Transport suck as TCP. More...

#include <src/main/activemq/transport/mock/MockTransport.h>

Inheritance diagram for activemq::transport::mock::MockTransport:

Public Member Functions

 MockTransport (const Pointer< wireformat::WireFormat > wireFormat, const Pointer< ResponseBuilder > responseBuilder)
virtual ~MockTransport ()
virtual void fireCommand (const Pointer< Command > command)
 Fires a Command back through this transport to its registered CommandListener if there is one.
virtual void fireException (const exceptions::ActiveMQException &ex)
 Fires a Exception back through this transport to its registered ExceptionListener if there is one.
void setResponseBuilder (const Pointer< ResponseBuilder > responseBuilder)
 Sets the ResponseBuilder that this class uses to create Responses to Commands sent.
virtual void setOutgoingListener (TransportListener *listener)
 Sets a Listener that gets notified for every command that would have been sent by this transport to the Broker, this allows a client to verify that its messages are making it to the wire.
Pointer< wireformat::WireFormatgetWireFormat () const
 Gets the currently set WireFormat.
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 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 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 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 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.
virtual std::string getRemoteAddress () const
virtual void reconnect (const decaf::net::URI &uri AMQCPP_UNUSED)
std::string getName () const
void setName (const std::string &name)
bool isFailOnSendMessage () const
void setFailOnSendMessage (bool value)
int getNumSentMessageBeforeFail () const
void setNumSentMessageBeforeFail (int value)
int getNumSentMessages () const
void setNumSentMessages (int value)
bool isFailOnReceiveMessage () const
void setFailOnReceiveMessage (bool value)
int getNumReceivedMessageBeforeFail () const
void setNumReceivedMessageBeforeFail (int value)
int getNumReceivedMessages () const
void setNumReceivedMessages (int value)
bool isFailOnKeepAliveSends () const
void setFailOnKeepAliveSends (bool value)
int getNumSentKeepAlivesBeforeFail () const
void setNumSentKeepAlivesBeforeFail (int value)
int getNumSentKeepAlives () const
void setNumSentKeepAlives (int value)
bool isFailOnStart () const
void setFailOnStart (bool value)
bool isFailOnStop () const
void setFailOnStop (bool value)
bool isFailOnClose () const
void setFailOnClose (bool value)
virtual bool isReconnectSupported () const
virtual bool isUpdateURIsSupported () const
virtual void updateURIs (bool rebalance AMQCPP_UNUSED, const decaf::util::List< decaf::net::URI > &uris AMQCPP_UNUSED)
- Public Member Functions inherited from activemq::transport::Transport
virtual ~Transport ()
virtual void reconnect (const decaf::net::URI &uri)=0
 reconnect to another location
virtual void updateURIs (bool rebalance, const decaf::util::List< decaf::net::URI > &uris)=0
 Updates the set of URIs the Transport can connect to.
- Public Member Functions inherited from decaf::io::Closeable
virtual ~Closeable ()

Static Public Member Functions

static MockTransportgetInstance ()

Detailed Description

The MockTransport defines a base level Transport class that is intended to be used in place of an a regular protocol Transport suck as TCP.

This Transport assumes that it is the base Transport in the Transports stack, and destroys any Transports that are passed to it in its constructor.

This Transport defines an Interface ResponseBuilder which must be implemented by any protocol for which the Transport is used to Emulate. The Transport hands off all outbound commands to the ResponseBuilder for processing, it is up to the builder to create appropriate responses and schedule any asynchronous messages that might result from a message sent to the Broker.

Constructor & Destructor Documentation

activemq::transport::mock::MockTransport::MockTransport ( const Pointer< wireformat::WireFormat wireFormat,
const Pointer< ResponseBuilder responseBuilder 
)
virtual activemq::transport::mock::MockTransport::~MockTransport ( )
inlinevirtual

Member Function Documentation

virtual Pointer<FutureResponse> activemq::transport::mock::MockTransport::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::mock::MockTransport::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.

virtual void activemq::transport::mock::MockTransport::fireCommand ( const Pointer< Command command)
inlinevirtual

Fires a Command back through this transport to its registered CommandListener if there is one.

Parameters
command- Command to send to the Listener.

References NULL.

virtual void activemq::transport::mock::MockTransport::fireException ( const exceptions::ActiveMQException ex)
inlinevirtual

Fires a Exception back through this transport to its registered ExceptionListener if there is one.

Parameters
exThe Exception that will be passed on the the Transport listener.

References NULL.

static MockTransport* activemq::transport::mock::MockTransport::getInstance ( )
inlinestatic
std::string activemq::transport::mock::MockTransport::getName ( ) const
inline
int activemq::transport::mock::MockTransport::getNumReceivedMessageBeforeFail ( ) const
inline
int activemq::transport::mock::MockTransport::getNumReceivedMessages ( ) const
inline
int activemq::transport::mock::MockTransport::getNumSentKeepAlives ( ) const
inline
int activemq::transport::mock::MockTransport::getNumSentKeepAlivesBeforeFail ( ) const
inline
int activemq::transport::mock::MockTransport::getNumSentMessageBeforeFail ( ) const
inline
int activemq::transport::mock::MockTransport::getNumSentMessages ( ) const
inline
virtual std::string activemq::transport::mock::MockTransport::getRemoteAddress ( ) const
inlinevirtual
Returns
the remote address for this connection

Implements activemq::transport::Transport.

virtual TransportListener* activemq::transport::mock::MockTransport::getTransportListener ( ) const
inlinevirtual

Gets the observer of asynchronous events from this transport.

Returns
the listener of transport events.

Implements activemq::transport::Transport.

Pointer<wireformat::WireFormat> activemq::transport::mock::MockTransport::getWireFormat ( ) const
inlinevirtual

Gets the currently set WireFormat.

Returns
the current WireFormat object.

Implements activemq::transport::Transport.

virtual bool activemq::transport::mock::MockTransport::isClosed ( ) const
inlinevirtual

Has the Transport been shutdown and no longer usable.

Returns
true if the Transport

Implements activemq::transport::Transport.

virtual bool activemq::transport::mock::MockTransport::isConnected ( ) const
inlinevirtual

Is the Transport Connected to its Broker.

Returns
true if a connection has been made.

Implements activemq::transport::Transport.

bool activemq::transport::mock::MockTransport::isFailOnClose ( ) const
inline
bool activemq::transport::mock::MockTransport::isFailOnKeepAliveSends ( ) const
inline
bool activemq::transport::mock::MockTransport::isFailOnReceiveMessage ( ) const
inline
bool activemq::transport::mock::MockTransport::isFailOnSendMessage ( ) const
inline
bool activemq::transport::mock::MockTransport::isFailOnStart ( ) const
inline
bool activemq::transport::mock::MockTransport::isFailOnStop ( ) const
inline
virtual bool activemq::transport::mock::MockTransport::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.

virtual bool activemq::transport::mock::MockTransport::isReconnectSupported ( ) const
inlinevirtual
Returns
true if reconnect is supported.

Implements activemq::transport::Transport.

virtual bool activemq::transport::mock::MockTransport::isUpdateURIsSupported ( ) const
inlinevirtual
Returns
true if updating uris is supported.

Implements activemq::transport::Transport.

virtual Transport* activemq::transport::mock::MockTransport::narrow ( const std::type_info &  typeId)
inlinevirtual

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.

References NULL.

virtual void activemq::transport::mock::MockTransport::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.

virtual void activemq::transport::mock::MockTransport::reconnect ( const decaf::net::URI &uri  AMQCPP_UNUSED)
inlinevirtual
virtual Pointer<Response> activemq::transport::mock::MockTransport::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::mock::MockTransport::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::mock::MockTransport::setFailOnClose ( bool  value)
inline
void activemq::transport::mock::MockTransport::setFailOnKeepAliveSends ( bool  value)
inline
void activemq::transport::mock::MockTransport::setFailOnReceiveMessage ( bool  value)
inline
void activemq::transport::mock::MockTransport::setFailOnSendMessage ( bool  value)
inline
void activemq::transport::mock::MockTransport::setFailOnStart ( bool  value)
inline
void activemq::transport::mock::MockTransport::setFailOnStop ( bool  value)
inline
void activemq::transport::mock::MockTransport::setName ( const std::string &  name)
inline
void activemq::transport::mock::MockTransport::setNumReceivedMessageBeforeFail ( int  value)
inline
void activemq::transport::mock::MockTransport::setNumReceivedMessages ( int  value)
inline
void activemq::transport::mock::MockTransport::setNumSentKeepAlives ( int  value)
inline
void activemq::transport::mock::MockTransport::setNumSentKeepAlivesBeforeFail ( int  value)
inline
void activemq::transport::mock::MockTransport::setNumSentMessageBeforeFail ( int  value)
inline
void activemq::transport::mock::MockTransport::setNumSentMessages ( int  value)
inline
virtual void activemq::transport::mock::MockTransport::setOutgoingListener ( TransportListener listener)
inlinevirtual

Sets a Listener that gets notified for every command that would have been sent by this transport to the Broker, this allows a client to verify that its messages are making it to the wire.

Parameters
listener- The CommandListener to notify for each message
void activemq::transport::mock::MockTransport::setResponseBuilder ( const Pointer< ResponseBuilder responseBuilder)
inline

Sets the ResponseBuilder that this class uses to create Responses to Commands sent.

These are either real Response Objects, or Commands that would have been sent Asynchronously be the Broker.

Parameters
responseBuilder- The ResponseBuilder to use from now on.
virtual void activemq::transport::mock::MockTransport::setTransportListener ( TransportListener listener)
inlinevirtual

Sets the observer of asynchronous events from this transport.

Parameters
listenerthe listener of transport events.

Implements activemq::transport::Transport.

virtual void activemq::transport::mock::MockTransport::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::mock::MockTransport::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::mock::MockTransport::stop ( )
virtual

Stops the Transport.

Exceptions
IOExceptionif an error occurs while stopping the transport.

Implements activemq::transport::Transport.

virtual void activemq::transport::mock::MockTransport::updateURIs ( bool rebalance  AMQCPP_UNUSED,
const decaf::util::List< decaf::net::URI > &uris  AMQCPP_UNUSED 
)
inlinevirtual

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