activemq::transport::ResponseCorrelator Class Reference

#include <ResponseCorrelator.h>

Inheritance diagram for activemq::transport::ResponseCorrelator:

activemq::transport::TransportFilter activemq::transport::Transport activemq::transport::CommandListener activemq::transport::TransportExceptionListener List of all members.

Public Member Functions

 ResponseCorrelator (Transport *next, const bool own=true)
virtual ~ResponseCorrelator ()
virtual unsigned long getMaxResponseWaitTime () const
virtual void setMaxResponseWaitTime (const unsigned long milliseconds)
virtual void oneway (Command *command) throw ( CommandIOException, exceptions::UnsupportedOperationException )
virtual Responserequest (Command *command) throw ( CommandIOException, exceptions::UnsupportedOperationException )
virtual void onCommand (Command *command)
virtual void setCommandListener (CommandListener *listener)
virtual void setTransportExceptionListener (TransportExceptionListener *listener)
virtual void start () throw ( cms::CMSException )
virtual void close () throw ( cms::CMSException )

Private Member Functions

unsigned int getNextCommandId () throw ( exceptions::ActiveMQException )

Private Attributes

unsigned int nextCommandId
std::map< unsigned int, FutureResponse * > requestMap
unsigned long maxResponseWaitTime
concurrent::Mutex commandIdMutex
concurrent::Mutex mapMutex
bool closed

Detailed Description

This type of transport filter is responsible for correlating asynchronous responses with requests. Non-response messages are simply sent directly to the CommandListener. It owns the transport that it


Constructor & Destructor Documentation

activemq::transport::ResponseCorrelator::ResponseCorrelator Transport next,
const bool  own = true
[inline]
 

Constructor.

Parameters:
next the next transport in the chain
own indicates if this transport owns the next

virtual activemq::transport::ResponseCorrelator::~ResponseCorrelator  )  [inline, virtual]
 


Member Function Documentation

virtual void activemq::transport::ResponseCorrelator::close void   )  throw ( cms::CMSException ) [inline, virtual]
 

Stops the polling thread and closes the streams. This can be called explicitly, but is also called in the destructor. Once this object has been closed, it cannot be restarted.

Exceptions:
CMSException if errors occur.

Reimplemented from activemq::transport::TransportFilter.

virtual unsigned long activemq::transport::ResponseCorrelator::getMaxResponseWaitTime  )  const [inline, virtual]
 

Gets the maximum wait time for a response in milliseconds.

Returns:
max time that a response can take

unsigned int activemq::transport::ResponseCorrelator::getNextCommandId  )  throw ( exceptions::ActiveMQException ) [inline, private]
 

Returns the next available command id.

virtual void activemq::transport::ResponseCorrelator::onCommand Command command  )  [inline, virtual]
 

This is called in the context of the nested transport's reading thread. In the case of a response object, updates the request map and notifies those waiting on the response. Non-response messages are just delegated to the command listener.

Parameters:
command the received from the nested transport.

Reimplemented from activemq::transport::TransportFilter.

virtual void activemq::transport::ResponseCorrelator::oneway Command command  )  throw ( CommandIOException, exceptions::UnsupportedOperationException ) [inline, virtual]
 

Sends a one-way command. Does not wait for any response from the broker.

Parameters:
command the command to be sent.
Exceptions:
CommandIOException if an exception occurs during writing of the command.
UnsupportedOperationException if this method is not implemented by this transport.

Reimplemented from activemq::transport::TransportFilter.

virtual Response* activemq::transport::ResponseCorrelator::request Command command  )  throw ( CommandIOException, exceptions::UnsupportedOperationException ) [inline, virtual]
 

Sends the given request to the server and waits for the response.

Parameters:
command The request to send.
Returns:
the response from the server. This may be of type ExceptionResponse in the case of a distributed error that occurs at the broker.
Exceptions:
CommandIOException if an error occurs with the request.

Reimplemented from activemq::transport::TransportFilter.

virtual void activemq::transport::ResponseCorrelator::setCommandListener CommandListener listener  )  [inline, virtual]
 

Assigns the command listener for non-response commands.

Parameters:
listener the listener.

Reimplemented from activemq::transport::TransportFilter.

virtual void activemq::transport::ResponseCorrelator::setMaxResponseWaitTime const unsigned long  milliseconds  )  [inline, virtual]
 

Sets the maximum wait time for a response in milliseconds.

Parameters:
milliseconds the max time that a response can take.

virtual void activemq::transport::ResponseCorrelator::setTransportExceptionListener TransportExceptionListener listener  )  [inline, virtual]
 

Sets the observer of asynchronous exceptions from this transport.

Parameters:
listener the listener of transport exceptions.

Reimplemented from activemq::transport::TransportFilter.

virtual void activemq::transport::ResponseCorrelator::start  )  throw ( cms::CMSException ) [inline, virtual]
 

Starts this transport object and creates the thread for polling on the input stream for commands. If this object has been closed, throws an exception. Before calling start, the caller must set the IO streams and the reader and writer objects.

Exceptions:
CMSException if an error occurs or if this transport has already been closed.
We're already started.

Reimplemented from activemq::transport::TransportFilter.


Member Data Documentation

bool activemq::transport::ResponseCorrelator::closed [private]
 

Flag to indicate the closed state.

concurrent::Mutex activemq::transport::ResponseCorrelator::commandIdMutex [private]
 

Sync object for accessing the next command id variable.

concurrent::Mutex activemq::transport::ResponseCorrelator::mapMutex [private]
 

Sync object for accessing the request map.

unsigned long activemq::transport::ResponseCorrelator::maxResponseWaitTime [private]
 

Maximum amount of time in milliseconds to wait for a response.

unsigned int activemq::transport::ResponseCorrelator::nextCommandId [private]
 

The next command id for sent commands.

std::map<unsigned int, FutureResponse*> activemq::transport::ResponseCorrelator::requestMap [private]
 

Map of request ids to future response objects.


The documentation for this class was generated from the following file:
Generated on Thu Aug 3 18:03:33 2006 for activemq-cpp by  doxygen 1.4.5