Apache Qpid C++ API
Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation

qpid::client::SubscriptionManager Class Reference
[Qpid C++ Client API]

A class to help create and manage subscriptions. More...

#include <SubscriptionManager.h>

List of all members.

Public Member Functions

 SubscriptionManager (const Session &session)
 Create a new SubscriptionManager associated with a session.
Subscription subscribe (MessageListener &listener, const std::string &queue, const SubscriptionSettings &settings, const std::string &name=std::string())
 Subscribe a MessagesListener to receive messages from queue.
Subscription subscribe (LocalQueue &localQueue, const std::string &queue, const SubscriptionSettings &settings, const std::string &name=std::string())
 Subscribe a LocalQueue to receive messages from queue.
Subscription subscribe (MessageListener &listener, const std::string &queue, const std::string &name=std::string())
 Subscribe a MessagesListener to receive messages from queue.
Subscription subscribe (LocalQueue &localQueue, const std::string &queue, const std::string &name=std::string())
 Subscribe a LocalQueue to receive messages from queue.
bool get (Message &result, const std::string &queue, sys::Duration timeout=0)
 Get a single message from a queue.
Message get (const std::string &queue, sys::Duration timeout=sys::TIME_INFINITE)
 Get a single message from a queue.
Subscription getSubscription (const std::string &name) const
 Get a subscription by name.
void cancel (const std::string &name)
 Cancel a subscription.
void run ()
 Deliver messages in the current thread until stop() is called.
void start ()
 Start a new thread to deliver messages.
void wait ()
 Wait for the thread started by a call to start() to complete.
void setAutoStop (bool set=true)
 If set true, run() will stop when all subscriptions are cancelled.
void stop ()
 Stop delivery.
void setFlowControl (const std::string &name, const FlowControl &flow)
 Set the flow control for a subscription.
void setFlowControl (const std::string &name, uint32_t messages, uint32_t bytes, bool window=true)
 Set the flow control for a subscription.
void setDefaultSettings (const SubscriptionSettings &s)
 Set the default settings for subscribe() calls that don't include a SubscriptionSettings parameter.
const SubscriptionSettingsgetDefaultSettings () const
 Get the default settings for subscribe() calls that don't include a SubscriptionSettings parameter.
SubscriptionSettingsgetDefaultSettings ()
 Get the default settings for subscribe() calls that don't include a SubscriptionSettings parameter.
void setFlowControl (uint32_t messages, uint32_t bytes, bool window=true)
 Set the default flow control settings for subscribe() calls that don't include a SubscriptionSettings parameter.
void setAcceptMode (AcceptMode mode)
 Set the default accept-mode for subscribe() calls that don't include a SubscriptionSettings parameter.
void setAcquireMode (AcquireMode mode)
 Set the default acquire-mode subscribe()s that don't specify SubscriptionSettings.
void registerFailoverHandler (boost::function< void()> fh)
Session getSession () const

Static Public Attributes

static const uint32_t UNLIMITED = 0xFFFFFFFF


Detailed Description

A class to help create and manage subscriptions.

Set up your subscriptions, then call run() to have messages delivered.

Subscribing and canceling subscriptions

Waiting for messages (and returning)

Definition at line 96 of file SubscriptionManager.h.


Constructor & Destructor Documentation

qpid::client::SubscriptionManager::SubscriptionManager ( const Session session  ) 

Create a new SubscriptionManager associated with a session.


Member Function Documentation

void qpid::client::SubscriptionManager::cancel ( const std::string &  name  ) 

Cancel a subscription.

See also: Subscription.cancel()

Referenced by qpid::client::AutoCancel::~AutoCancel().

Message qpid::client::SubscriptionManager::get ( const std::string &  queue,
sys::Duration  timeout = sys::TIME_INFINITE 
)

Get a single message from a queue.

Parameters:
timeout wait up this timeout for a message to appear.
Returns:
message from the queue.
Exceptions:
Exception if the timeout is exceeded.

bool qpid::client::SubscriptionManager::get ( Message result,
const std::string &  queue,
sys::Duration  timeout = 0 
)

Get a single message from a queue.

Parameters:
result is set to the message from the queue.
timeout wait up this timeout for a message to appear.
Returns:
true if result was set, false if no message available after timeout.

SubscriptionSettings& qpid::client::SubscriptionManager::getDefaultSettings (  )  [inline]

Get the default settings for subscribe() calls that don't include a SubscriptionSettings parameter.

Definition at line 236 of file SubscriptionManager.h.

const SubscriptionSettings& qpid::client::SubscriptionManager::getDefaultSettings (  )  const [inline]

Get the default settings for subscribe() calls that don't include a SubscriptionSettings parameter.

Definition at line 231 of file SubscriptionManager.h.

Session qpid::client::SubscriptionManager::getSession (  )  const

Subscription qpid::client::SubscriptionManager::getSubscription ( const std::string &  name  )  const

Get a subscription by name.

Exceptions:
Exception if not found.

void qpid::client::SubscriptionManager::registerFailoverHandler ( boost::function< void()>  fh  ) 

void qpid::client::SubscriptionManager::run (  ) 

Deliver messages in the current thread until stop() is called.

Only one thread may be running in a SubscriptionManager at a time.

See also:
run

void qpid::client::SubscriptionManager::setAcceptMode ( AcceptMode  mode  )  [inline]

Set the default accept-mode for subscribe() calls that don't include a SubscriptionSettings parameter.

Definition at line 254 of file SubscriptionManager.h.

References qpid::client::SubscriptionSettings::acceptMode.

void qpid::client::SubscriptionManager::setAcquireMode ( AcquireMode  mode  )  [inline]

Set the default acquire-mode subscribe()s that don't specify SubscriptionSettings.

Definition at line 259 of file SubscriptionManager.h.

References qpid::client::SubscriptionSettings::acquireMode.

void qpid::client::SubscriptionManager::setAutoStop ( bool  set = true  ) 

If set true, run() will stop when all subscriptions are cancelled.

If false, run will only stop when stop() is called. True by default.

void qpid::client::SubscriptionManager::setDefaultSettings ( const SubscriptionSettings s  )  [inline]

Set the default settings for subscribe() calls that don't include a SubscriptionSettings parameter.

Definition at line 226 of file SubscriptionManager.h.

void qpid::client::SubscriptionManager::setFlowControl ( uint32_t  messages,
uint32_t  bytes,
bool  window = true 
) [inline]

Set the default flow control settings for subscribe() calls that don't include a SubscriptionSettings parameter.

Parameters:
messages,: message credit.
bytes,: byte credit.
window,: if true use window-based flow control.

Definition at line 246 of file SubscriptionManager.h.

References qpid::client::SubscriptionSettings::flowControl.

void qpid::client::SubscriptionManager::setFlowControl ( const std::string &  name,
uint32_t  messages,
uint32_t  bytes,
bool  window = true 
)

Set the flow control for a subscription.

Parameters:
name,: name of the subscription.
messages,: message credit.
bytes,: byte credit.
window,: if true use window-based flow control.

void qpid::client::SubscriptionManager::setFlowControl ( const std::string &  name,
const FlowControl flow 
)

Set the flow control for a subscription.

void qpid::client::SubscriptionManager::start (  ) 

Start a new thread to deliver messages.

Only one thread may be running in a SubscriptionManager at a time.

See also:
start

void qpid::client::SubscriptionManager::stop (  ) 

Stop delivery.

Causes run() to return, or the thread started with start() to exit.

Subscription qpid::client::SubscriptionManager::subscribe ( LocalQueue localQueue,
const std::string &  queue,
const std::string &  name = std::string() 
)

Subscribe a LocalQueue to receive messages from queue.

Incoming messages are stored in the queue for you to retrieve.

Parameters:
queue Name of the queue to subscribe to.
name unique destination name for the subscription, defaults to queue name. If not specified, the queue name is used.

Subscription qpid::client::SubscriptionManager::subscribe ( MessageListener listener,
const std::string &  queue,
const std::string &  name = std::string() 
)

Subscribe a MessagesListener to receive messages from queue.

Provide your own subclass of MessagesListener to process incoming messages. It will be called for each message received.

Parameters:
listener Listener object to receive messages.
queue Name of the queue to subscribe to.
name unique destination name for the subscription, defaults to queue name. If not specified, the queue name is used.

Subscription qpid::client::SubscriptionManager::subscribe ( LocalQueue localQueue,
const std::string &  queue,
const SubscriptionSettings settings,
const std::string &  name = std::string() 
)

Subscribe a LocalQueue to receive messages from queue.

Incoming messages are stored in the queue for you to retrieve.

Parameters:
queue Name of the queue to subscribe to.
flow initial FlowControl for the subscription.
name unique destination name for the subscription, defaults to queue name. If not specified, the queue name is used.

Subscription qpid::client::SubscriptionManager::subscribe ( MessageListener listener,
const std::string &  queue,
const SubscriptionSettings settings,
const std::string &  name = std::string() 
)

Subscribe a MessagesListener to receive messages from queue.

Provide your own subclass of MessagesListener to process incoming messages. It will be called for each message received.

Parameters:
listener Listener object to receive messages.
queue Name of the queue to subscribe to.
settings settings for the subscription.
name unique destination name for the subscription, defaults to queue name.

void qpid::client::SubscriptionManager::wait (  ) 

Wait for the thread started by a call to start() to complete.


Member Data Documentation

const uint32_t qpid::client::SubscriptionManager::UNLIMITED = 0xFFFFFFFF [static]

Definition at line 210 of file SubscriptionManager.h.


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

Qpid C++ API Reference
Generated on Mon Mar 16 13:47:29 2009 for Qpid C++ Client API by doxygen 1.5.8