00001 #ifndef QPID_CLIENT_FAILOVERSESSION_H
00002 #define QPID_CLIENT_FAILOVERSESSION_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/SessionId.h"
00027 #include "qpid/framing/amqp_structs.h"
00028 #include "qpid/framing/ProtocolVersion.h"
00029 #include "qpid/framing/MethodContent.h"
00030 #include "qpid/framing/TransferContent.h"
00031 #include "qpid/client/Completion.h"
00032 #include "qpid/client/Connection.h"
00033 #include "qpid/client/ConnectionImpl.h"
00034 #include "qpid/client/Execution.h"
00035 #include "qpid/client/SessionImpl.h"
00036 #include "qpid/client/TypedResult.h"
00037 #include "qpid/shared_ptr.h"
00038 #include "qpid/sys/Mutex.h"
00039
00040 #include <string>
00041
00042
00043
00044
00045 namespace qpid {
00046 namespace client {
00047
00048
00049 class FailoverConnection;
00050 class FailoverSubscriptionManager;
00051
00052
00053 class FailoverSession
00054 {
00055 public:
00056
00057 typedef framing::TransferContent DefaultContent;
00058
00059 FailoverSession ( );
00060 ~FailoverSession ( );
00061
00062 std::string name;
00063
00064 framing::FrameSet::shared_ptr get();
00065
00066 SessionId getId() const;
00067
00068 void close();
00069
00070 void sync();
00071
00072 uint32_t timeout ( uint32_t seconds);
00073
00074 Execution& getExecution();
00075
00076 void flush();
00077
00078 void markCompleted(const framing::SequenceNumber& id,
00079 bool cumulative,
00080 bool notifyPeer
00081 );
00082
00083 void sendCompletion ( );
00084
00085
00086
00087
00088
00089 void
00090 executionSync();
00091
00092
00093 void
00094 executionResult(const SequenceNumber& commandId=SequenceNumber(),
00095 const string& value=string());
00096
00097
00098 void
00099 executionException(uint16_t errorCode=0,
00100 const SequenceNumber& commandId=SequenceNumber(),
00101 uint8_t classCode=0,
00102 uint8_t commandCode=0,
00103 uint8_t fieldIndex=0,
00104 const string& description=string(),
00105 const FieldTable& errorInfo=FieldTable());
00106
00107
00108 void
00109 messageTransfer(const string& destination=string(),
00110 uint8_t acceptMode=1,
00111 uint8_t acquireMode=0,
00112 const MethodContent& content=DefaultContent(std::string()));
00113
00114
00115 void
00116 messageAccept(const SequenceSet& transfers=SequenceSet());
00117
00118
00119 void
00120 messageReject(const SequenceSet& transfers=SequenceSet(),
00121 uint16_t code=0,
00122 const string& text=string());
00123
00124
00125 void
00126 messageRelease(const SequenceSet& transfers=SequenceSet(),
00127 bool setRedelivered=false);
00128
00129
00130 qpid::framing::MessageAcquireResult
00131 messageAcquire(const SequenceSet& transfers=SequenceSet());
00132
00133
00134 qpid::framing::MessageResumeResult
00135 messageResume(const string& destination=string(),
00136 const string& resumeId=string());
00137
00138
00139 void
00140 messageSubscribe(const string& queue=string(),
00141 const string& destination=string(),
00142 uint8_t acceptMode=0,
00143 uint8_t acquireMode=0,
00144 bool exclusive=false,
00145 const string& resumeId=string(),
00146 uint64_t resumeTtl=0,
00147 const FieldTable& arguments=FieldTable());
00148
00149
00150 void
00151 messageCancel(const string& destination=string());
00152
00153
00154 void
00155 messageSetFlowMode(const string& destination=string(),
00156 uint8_t flowMode=0);
00157
00158
00159 void
00160 messageFlow(const string& destination=string(),
00161 uint8_t unit=0,
00162 uint32_t value=0);
00163
00164
00165 void
00166 messageFlush(const string& destination=string());
00167
00168
00169 void
00170 messageStop(const string& destination=string());
00171
00172
00173 void
00174 txSelect();
00175
00176
00177 void
00178 txCommit();
00179
00180
00181 void
00182 txRollback();
00183
00184
00185 void
00186 dtxSelect();
00187
00188
00189 qpid::framing::XaResult
00190 dtxStart(const Xid& xid=Xid(),
00191 bool join=false,
00192 bool resume=false);
00193
00194
00195 qpid::framing::XaResult
00196 dtxEnd(const Xid& xid=Xid(),
00197 bool fail=false,
00198 bool suspend=false);
00199
00200
00201 qpid::framing::XaResult
00202 dtxCommit(const Xid& xid=Xid(),
00203 bool onePhase=false);
00204
00205
00206 void
00207 dtxForget(const Xid& xid=Xid());
00208
00209
00210 qpid::framing::DtxGetTimeoutResult
00211 dtxGetTimeout(const Xid& xid=Xid());
00212
00213
00214 qpid::framing::XaResult
00215 dtxPrepare(const Xid& xid=Xid());
00216
00217
00218 qpid::framing::DtxRecoverResult
00219 dtxRecover();
00220
00221
00222 qpid::framing::XaResult
00223 dtxRollback(const Xid& xid=Xid());
00224
00225
00226 void
00227 dtxSetTimeout(const Xid& xid=Xid(),
00228 uint32_t timeout=0);
00229
00230
00231 void
00232 exchangeDeclare(const string& exchange=string(),
00233 const string& type=string(),
00234 const string& alternateExchange=string(),
00235 bool passive=false,
00236 bool durable=false,
00237 bool autoDelete=false,
00238 const FieldTable& arguments=FieldTable());
00239
00240
00241 void
00242 exchangeDelete(const string& exchange=string(),
00243 bool ifUnused=false);
00244
00245
00246 qpid::framing::ExchangeQueryResult
00247 exchangeQuery(const string& name=string());
00248
00249
00250 void
00251 exchangeBind(const string& queue=string(),
00252 const string& exchange=string(),
00253 const string& bindingKey=string(),
00254 const FieldTable& arguments=FieldTable());
00255
00256
00257 void
00258 exchangeUnbind(const string& queue=string(),
00259 const string& exchange=string(),
00260 const string& bindingKey=string());
00261
00262
00263 qpid::framing::ExchangeBoundResult
00264 exchangeBound(const string& exchange=string(),
00265 const string& queue=string(),
00266 const string& bindingKey=string(),
00267 const FieldTable& arguments=FieldTable());
00268
00269
00270 void
00271 queueDeclare(const string& queue=string(),
00272 const string& alternateExchange=string(),
00273 bool passive=false,
00274 bool durable=false,
00275 bool exclusive=false,
00276 bool autoDelete=false,
00277 const FieldTable& arguments=FieldTable());
00278
00279
00280 void
00281 queueDelete(const string& queue=string(),
00282 bool ifUnused=false,
00283 bool ifEmpty=false);
00284
00285
00286 void
00287 queuePurge(const string& queue=string());
00288
00289
00290 qpid::framing::QueueQueryResult
00291 queueQuery(const string& queue=string());
00292
00293
00294
00295
00296 void prepareForFailover ( Connection newConnection );
00297
00298 void failover ( );
00299
00300 void setFailoverSubscriptionManager(FailoverSubscriptionManager*);
00301
00302 private:
00303 typedef sys::Mutex::ScopedLock Lock;
00304 sys::Mutex lock;
00305
00306 FailoverSubscriptionManager * failoverSubscriptionManager;
00307
00308 Session session;
00309 Session newSession;
00310
00311 friend class FailoverConnection;
00312 friend class FailoverSubscriptionManager;
00313 };
00314
00315 }}
00316
00317
00318 #endif