#include <SubscriptionManager.h>
Public Member Functions | |
SubscriptionManager (const Session &session) | |
Create a new SubscriptionManager associated with a session. | |
void | subscribe (MessageListener &listener, const std::string &queue, const FlowControl &flow, const std::string &tag=std::string()) |
Subscribe a MessagesListener to receive messages from queue. | |
void | subscribe (LocalQueue &localQueue, const std::string &queue, const FlowControl &flow, const std::string &tag=std::string()) |
Subscribe a LocalQueue to receive messages from queue. | |
void | subscribe (MessageListener &listener, const std::string &queue, const std::string &tag=std::string()) |
Subscribe a MessagesListener to receive messages from queue. | |
void | subscribe (LocalQueue &localQueue, const std::string &queue, const std::string &tag=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. | |
void | cancel (const std::string tag) |
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 | setAutoStop (bool set=true) |
If set true, run() will stop when all subscriptions are cancelled. | |
void | stop () |
Stop delivery. | |
void | setFlowControl (const std::string &destintion, const FlowControl &flow) |
Set the flow control for destination. | |
void | setFlowControl (const FlowControl &flow) |
Set the default initial flow control for subscriptions that do not specify it. | |
const FlowControl & | getFlowControl () const |
Get the default flow control for new subscriptions that do not specify it. | |
void | setFlowControl (const std::string &tag, uint32_t messages, uint32_t bytes, bool window=true) |
Set the flow control for destination tag. | |
void | setFlowControl (uint32_t messages, uint32_t bytes, bool window=true) |
Set the initial flow control settings to be applied to each new subscribtion. | |
void | setAcceptMode (bool required) |
Set the accept-mode for new subscriptions. | |
void | setAcquireMode (bool acquire) |
Set the acquire-mode for new subscriptions. | |
void | setAckPolicy (const AckPolicy &autoAck) |
Set the acknowledgement policy for new subscriptions. | |
AckPolicy & | getAckPolicy () |
void | registerFailoverHandler (boost::function< void()> fh) |
Session | getSession () const |
Static Public Attributes | |
static const uint32_t | UNLIMITED = 0xFFFFFFFF |
Set up your subscriptions, then call run() to have messages delivered.
Definition at line 46 of file SubscriptionManager.h.
void qpid::client::SubscriptionManager::subscribe | ( | MessageListener & | listener, | |
const std::string & | queue, | |||
const FlowControl & | flow, | |||
const std::string & | tag = 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.
listener | Listener object to receive messages. | |
queue | Name of the queue to subscribe to. | |
flow | initial FlowControl for the subscription. | |
tag | Unique destination tag for the listener. If not specified, the queue name is used. |
void qpid::client::SubscriptionManager::subscribe | ( | LocalQueue & | localQueue, | |
const std::string & | queue, | |||
const FlowControl & | flow, | |||
const std::string & | tag = std::string() | |||
) |
Subscribe a LocalQueue to receive messages from queue.
Incoming messages are stored in the queue for you to retrieve.
queue | Name of the queue to subscribe to. | |
flow | initial FlowControl for the subscription. | |
tag | Unique destination tag for the listener. If not specified, the queue name is used. |
void qpid::client::SubscriptionManager::subscribe | ( | MessageListener & | listener, | |
const std::string & | queue, | |||
const std::string & | tag = 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.
listener | Listener object to receive messages. | |
queue | Name of the queue to subscribe to. | |
tag | Unique destination tag for the listener. If not specified, the queue name is used. |
void qpid::client::SubscriptionManager::subscribe | ( | LocalQueue & | localQueue, | |
const std::string & | queue, | |||
const std::string & | tag = std::string() | |||
) |
Subscribe a LocalQueue to receive messages from queue.
Incoming messages are stored in the queue for you to retrieve.
queue | Name of the queue to subscribe to. | |
tag | Unique destination tag for the listener. If not specified, the queue name is used. |
bool qpid::client::SubscriptionManager::get | ( | Message & | result, | |
const std::string & | queue, | |||
sys::Duration | timeout = 0 | |||
) |
Get a single message from a queue.
result | is set to the message from the queue. @ | |
timeout | wait up this timeout for a message to appear. |
void qpid::client::SubscriptionManager::cancel | ( | const std::string | tag | ) |
Cancel a subscription.
void qpid::client::SubscriptionManager::run | ( | ) | [virtual] |
Deliver messages in the current thread until stop() is called.
Only one thread may be running in a SubscriptionManager at a time.
Implements qpid::sys::Runnable.
void qpid::client::SubscriptionManager::start | ( | ) |
Start a new thread to deliver messages.
Only one thread may be running in a SubscriptionManager at a time.
void qpid::client::SubscriptionManager::setAutoStop | ( | bool | set = true |
) |
void qpid::client::SubscriptionManager::stop | ( | ) |
void qpid::client::SubscriptionManager::setFlowControl | ( | const std::string & | destintion, | |
const FlowControl & | flow | |||
) |
Set the flow control for destination.
void qpid::client::SubscriptionManager::setFlowControl | ( | const FlowControl & | flow | ) |
Set the default initial flow control for subscriptions that do not specify it.
const FlowControl& qpid::client::SubscriptionManager::getFlowControl | ( | ) | const |
Get the default flow control for new subscriptions that do not specify it.
void qpid::client::SubscriptionManager::setFlowControl | ( | const std::string & | tag, | |
uint32_t | messages, | |||
uint32_t | bytes, | |||
bool | window = true | |||
) |
Set the flow control for destination tag.
tag,: | name of the destination. | |
messages,: | message credit. | |
bytes,: | byte credit. | |
window,: | if true use window-based flow control. |
void qpid::client::SubscriptionManager::setFlowControl | ( | uint32_t | messages, | |
uint32_t | bytes, | |||
bool | window = true | |||
) |
Set the initial flow control settings to be applied to each new subscribtion.
messages,: | message credit. | |
bytes,: | byte credit. | |
window,: | if true use window-based flow control. |
void qpid::client::SubscriptionManager::setAcceptMode | ( | bool | required | ) |
Set the accept-mode for new subscriptions.
Defaults to true.
required,: | if true messages must be confirmed by calling Message::acknowledge() or automatically, see setAckPolicy() |
void qpid::client::SubscriptionManager::setAcquireMode | ( | bool | acquire | ) |
Set the acquire-mode for new subscriptions.
Defaults to false.
acquire,: | if false messages pre-acquired, if true messages are dequed on acknowledgement or on transfer depending on acceptMode. |
void qpid::client::SubscriptionManager::setAckPolicy | ( | const AckPolicy & | autoAck | ) |
Set the acknowledgement policy for new subscriptions.
Default is to acknowledge every message automatically.