From 4d560b89fa09056c22cd42e212c9ce8addeecb5a Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Wed, 25 Jun 2008 20:51:30 +0000 Subject: Additions to the client API: - SubscriptionManager::get(queue) to get a single message from a queue. - Set FlowControl per-subscription. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@671655 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/client/SubscriptionManager.h | 55 +++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 6 deletions(-) (limited to 'cpp/src/qpid/client/SubscriptionManager.h') diff --git a/cpp/src/qpid/client/SubscriptionManager.h b/cpp/src/qpid/client/SubscriptionManager.h index 930175564e..0aa55099f5 100644 --- a/cpp/src/qpid/client/SubscriptionManager.h +++ b/cpp/src/qpid/client/SubscriptionManager.h @@ -27,8 +27,8 @@ #include #include #include +#include #include - #include #include @@ -48,13 +48,11 @@ class SubscriptionManager : public sys::Runnable typedef sys::Mutex::ScopedLock Lock; typedef sys::Mutex::ScopedUnlock Unlock; - void subscribeInternal(const std::string& q, const std::string& dest); + void subscribeInternal(const std::string& q, const std::string& dest, const FlowControl&); qpid::client::Dispatcher dispatcher; qpid::client::AsyncSession session; - uint32_t messages; - uint32_t bytes; - bool window; + FlowControl flowControl; AckPolicy autoAck; bool acceptMode; bool acquireMode; @@ -64,6 +62,38 @@ class SubscriptionManager : public sys::Runnable /** Create a new SubscriptionManager associated with a session */ SubscriptionManager(const Session& session); + /** + * 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. + * + *@param listener Listener object to receive messages. + *@param queue Name of the queue to subscribe to. + *@param flow initial FlowControl for the subscription. + *@param tag Unique destination tag for the listener. + * If not specified, the queue name is used. + */ + void subscribe(MessageListener& listener, + 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. + * + *@param queue Name of the queue to subscribe to. + *@param flow initial FlowControl for the subscription. + *@param tag Unique destination tag for the listener. + * If not specified, the queue name is used. + */ + void subscribe(LocalQueue& localQueue, + const std::string& queue, + const FlowControl& flow, + const std::string& tag=std::string()); + /** * Subscribe a MessagesListener to receive messages from queue. * @@ -92,6 +122,11 @@ class SubscriptionManager : public sys::Runnable const std::string& queue, const std::string& tag=std::string()); + /** + * Get a single message from a queue. + */ + Message get(const std::string& queue); + /** Cancel a subscription. */ void cancel(const std::string tag); @@ -107,9 +142,17 @@ class SubscriptionManager : public sys::Runnable /** Cause run() to return */ void stop(); - static const uint32_t UNLIMITED=0xFFFFFFFF; + /** Set the flow control for destination. */ + void setFlowControl(const std::string& destintion, const FlowControl& flow); + + /** Set the default initial flow control for subscriptions that do not specify it. */ + void setFlowControl(const FlowControl& flow); + + /** Get the default flow control for new subscriptions that do not specify it. */ + const FlowControl& getFlowControl() const; + /** Set the flow control for destination tag. *@param tag: name of the destination. *@param messages: message credit. -- cgit v1.2.1