00001 #ifndef QPID_CLIENT_FAILOVERSUBSCRIPTIONMANAGER_H
00002 #define QPID_CLIENT_FAILOVERSUBSCRIPTIONMANAGER_H
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "qpid/sys/Mutex.h"
00027 #include <qpid/client/Dispatcher.h>
00028 #include <qpid/client/Completion.h>
00029 #include <qpid/client/Session.h>
00030 #include <qpid/client/FailoverSession.h>
00031 #include <qpid/client/MessageListener.h>
00032 #include <qpid/client/SubscriptionManager.h>
00033 #include <qpid/client/LocalQueue.h>
00034 #include <qpid/client/FlowControl.h>
00035 #include <qpid/sys/Runnable.h>
00036 #include <qpid/sys/Monitor.h>
00037
00038
00039
00040
00041 namespace qpid {
00042 namespace client {
00043
00044
00045 class FailoverSubscriptionManager
00046 {
00047 public:
00048
00049 FailoverSubscriptionManager ( FailoverSession * fs );
00050
00051 void subscribe ( MessageListener & listener,
00052 const std::string & queue,
00053 const FlowControl & flow,
00054 const std::string & tag = std::string(),
00055 bool record_this = true );
00056
00057 void subscribe ( LocalQueue & localQueue,
00058 const std::string & queue,
00059 const FlowControl & flow,
00060 const std::string & tag=std::string(),
00061 bool record_this = true );
00062
00063 void subscribe ( MessageListener & listener,
00064 const std::string & queue,
00065 const std::string & tag = std::string(),
00066 bool record_this = true );
00067
00068 void subscribe ( LocalQueue & localQueue,
00069 const std::string & queue,
00070 const std::string & tag=std::string(),
00071 bool record_this = true );
00072
00073 bool get ( Message & result,
00074 const std::string & queue,
00075 sys::Duration timeout=0);
00076
00077 void cancel ( const std::string tag );
00078
00079 void run ( );
00080
00081 void start ( );
00082
00083 void setAutoStop ( bool set = true );
00084
00085 void stop ( );
00086
00087 void setFlowControl ( const std::string & destintion,
00088 const FlowControl & flow );
00089
00090 void setFlowControl ( const FlowControl & flow );
00091
00092 const FlowControl & getFlowControl ( ) const;
00093
00094 void setFlowControl ( const std::string & tag,
00095 uint32_t messages,
00096 uint32_t bytes,
00097 bool window=true );
00098
00099 void setFlowControl ( uint32_t messages,
00100 uint32_t bytes,
00101 bool window = true
00102 );
00103
00104 void setAcceptMode ( bool required );
00105
00106 void setAcquireMode ( bool acquire );
00107
00108 void setAckPolicy ( const AckPolicy & autoAck );
00109
00110 AckPolicy & getAckPolicy();
00111
00112
00113
00114 void prepareForFailover ( Session newSession );
00115 void failover ( );
00116
00117 std::string name;
00118
00119
00120
00121 private:
00122 sys::Monitor lock;
00123
00124 SubscriptionManager * subscriptionManager;
00125
00126 MessageListener * savedListener;
00127 std::string savedQueue,
00128 savedTag;
00129
00130 friend class FailoverConnection;
00131 friend class FailoverSession;
00132
00133 Session newSession;
00134 bool newSessionIsValid;
00135 bool no_failover;
00136
00137
00138 typedef boost::function<void ()> subscribeFn;
00139 std::vector < subscribeFn > subscribeFns;
00140 };
00141
00142 }}
00143
00144
00145 #endif