Go to the documentation of this file.00001 #ifndef QPID_CLIENT_SUBSCRIPTIONMANAGER_H
00002 #define QPID_CLIENT_SUBSCRIPTIONMANAGER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "qpid/client/Session.h"
00026 #include "qpid/client/Subscription.h"
00027 #include "qpid/sys/Runnable.h"
00028 #include "qpid/sys/Thread.h"
00029 #include "qpid/client/ClientImportExport.h"
00030 #include "qpid/client/MessageListener.h"
00031 #include "qpid/client/LocalQueue.h"
00032 #include "qpid/client/Handle.h"
00033 #include <string>
00034
00035 namespace qpid {
00036 namespace client {
00037
00038 class SubscriptionManagerImpl;
00039
00097 class QPID_CLIENT_CLASS_EXTERN SubscriptionManager : public sys::Runnable, public Handle<SubscriptionManagerImpl>
00098 {
00099 public:
00101 QPID_CLIENT_EXTERN SubscriptionManager(const Session& session);
00102 QPID_CLIENT_EXTERN SubscriptionManager(const SubscriptionManager&);
00103 QPID_CLIENT_EXTERN ~SubscriptionManager();
00104 QPID_CLIENT_EXTERN SubscriptionManager& operator=(const SubscriptionManager&);
00105
00117 QPID_CLIENT_EXTERN Subscription subscribe(MessageListener& listener,
00118 const std::string& queue,
00119 const SubscriptionSettings& settings,
00120 const std::string& name=std::string());
00121
00132 QPID_CLIENT_EXTERN Subscription subscribe(LocalQueue& localQueue,
00133 const std::string& queue,
00134 const SubscriptionSettings& settings,
00135 const std::string& name=std::string());
00136
00148 QPID_CLIENT_EXTERN Subscription subscribe(MessageListener& listener,
00149 const std::string& queue,
00150 const std::string& name=std::string());
00151
00161 QPID_CLIENT_EXTERN Subscription subscribe(LocalQueue& localQueue,
00162 const std::string& queue,
00163 const std::string& name=std::string());
00164
00165
00174 QPID_CLIENT_EXTERN bool get(Message& result, const std::string& queue, sys::Duration timeout=0);
00175
00184 QPID_CLIENT_EXTERN Message get(const std::string& queue, sys::Duration timeout=sys::TIME_INFINITE);
00185
00189 QPID_CLIENT_EXTERN Subscription getSubscription(const std::string& name) const;
00190
00192 QPID_CLIENT_EXTERN void cancel(const std::string& name);
00193
00198 QPID_CLIENT_EXTERN void run();
00199
00204 QPID_CLIENT_EXTERN void start();
00205
00209 QPID_CLIENT_EXTERN void wait();
00210
00215 QPID_CLIENT_EXTERN void setAutoStop(bool set=true);
00216
00218 QPID_CLIENT_EXTERN void stop();
00219
00220 static const uint32_t UNLIMITED=0xFFFFFFFF;
00221
00223 QPID_CLIENT_EXTERN void setFlowControl(const std::string& name, const FlowControl& flow);
00224
00231 QPID_CLIENT_EXTERN void setFlowControl(const std::string& name, uint32_t messages, uint32_t bytes, bool window=true);
00232
00236 QPID_CLIENT_EXTERN void setDefaultSettings(const SubscriptionSettings& s);
00237
00241 QPID_CLIENT_EXTERN const SubscriptionSettings& getDefaultSettings() const;
00242
00246 QPID_CLIENT_EXTERN SubscriptionSettings& getDefaultSettings();
00247
00256 QPID_CLIENT_EXTERN void setFlowControl(uint32_t messages, uint32_t bytes, bool window=true);
00257
00262 QPID_CLIENT_EXTERN void setAcceptMode(AcceptMode mode);
00263
00267 QPID_CLIENT_EXTERN void setAcquireMode(AcquireMode mode);
00268
00269 QPID_CLIENT_EXTERN void registerFailoverHandler ( boost::function<void ()> fh );
00270
00271 QPID_CLIENT_EXTERN Session getSession() const;
00272
00273 SubscriptionManager(SubscriptionManagerImpl*);
00274
00275 private:
00276 typedef SubscriptionManagerImpl Impl;
00277 friend class PrivateImplRef<SubscriptionManager>;
00278 };
00279
00281 class AutoCancel {
00282 public:
00283 AutoCancel(SubscriptionManager& sm_, const std::string& tag_) : sm(sm_), tag(tag_) {}
00284 ~AutoCancel() { sm.cancel(tag); }
00285 private:
00286 SubscriptionManager& sm;
00287 std::string tag;
00288 };
00289
00290 }}
00291
00292 #endif