00001 #ifndef QPID_CLIENT_FAILOVERCONNECTION_H
00002 #define QPID_CLIENT_FAILOVERCONNECTION_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 <string>
00027
00028 #include "qpid/client/Connection.h"
00029 #include "qpid/client/FailoverConnection.h"
00030 #include "qpid/client/FailoverSession.h"
00031 #include "qpid/client/FailoverSubscriptionManager.h"
00032 #include "qpid/sys/Mutex.h"
00033
00034
00035 namespace qpid {
00036 namespace client {
00037
00038 class ConnectionSettings;
00039
00040
00041 class FailoverConnection
00042 {
00043 public:
00044
00045 FailoverConnection ( );
00046
00047 ~FailoverConnection ( );
00048
00049 void open ( const std::string& host,
00050 int port,
00051 const std::string& uid = "guest",
00052 const std::string& pwd = "guest",
00053 const std::string& virtualhost = "/",
00054 uint16_t maxFrameSize=65535
00055 );
00056
00057 void open ( ConnectionSettings & settings );
00058
00059 void close ( );
00060
00061 FailoverSession * newSession ( const std::string& name = std::string() );
00062
00063 void resume ( FailoverSession & session );
00064
00065 bool isOpen() const;
00066
00067 void getKnownBrokers ( std::vector<std::string> & v );
00068
00069
00070
00071
00072 void registerFailureCallback ( boost::function<void ()> fn );
00073
00074
00075
00076 std::string name;
00077
00078 void failover ( );
00079
00080 struct timeval * failoverCompleteTime;
00081
00082
00083 private:
00084
00085 typedef sys::Mutex::ScopedLock Lock;
00086
00087 sys::Mutex lock;
00088
00089 Connection connection;
00090
00091 boost::function<void ()> clientFailoverCallback;
00092
00093 std::vector<FailoverSession *> sessions;
00094
00095
00096 friend class FailoverSession;
00097 friend class FailoverSessionManager;
00098 };
00099
00100 }}
00101
00102
00103 #endif