00001 /*------------------------------------------------------------------------------ 00002 Name: SQLiteQueuePlugin.h 00003 Project: xmlBlaster.org 00004 Copyright: xmlBlaster.org, see xmlBlaster-LICENSE file 00005 ------------------------------------------------------------------------------*/ 00006 #ifndef _UTIL_QUEUE_SQLITEQUEUE_H 00007 #define _UTIL_QUEUE_SQLITEQUEUE_H 00008 00009 #include <util/xmlBlasterDef.h> 00010 #include <util/ReferenceHolder.h> 00011 #include <util/queue/I_Queue.h> 00012 #include <util/queue/MsgQueueEntry.h> 00013 #include <util/qos/ConnectQosFactory.h> 00014 #include <util/qos/StatusQosFactory.h> 00015 #include <util/qos/MsgQosFactory.h> 00016 #include <util/key/MsgKeyFactory.h> 00017 #include <util/thread/ThreadImpl.h> 00018 #include <util/I_Log.h> 00019 00020 struct I_QueueStruct; 00021 struct ExceptionStruct; 00022 00023 namespace org { namespace xmlBlaster { namespace util { namespace queue { 00024 00036 class Dll_Export SQLiteQueuePlugin : public I_Queue 00037 { 00038 private: 00039 SQLiteQueuePlugin(const SQLiteQueuePlugin& queue); 00040 SQLiteQueuePlugin& operator =(const SQLiteQueuePlugin& queue); 00041 00042 protected: 00043 std::string ME; 00044 org::xmlBlaster::util::Global& global_; 00045 org::xmlBlaster::util::I_Log& log_; 00046 org::xmlBlaster::util::qos::storage::QueuePropertyBase property_; 00047 struct ::I_QueueStruct *queueP_; // The C based xmlBlaster SQLite queue implementation 00048 mutable org::xmlBlaster::util::qos::ConnectQosFactory connectQosFactory_; 00049 mutable org::xmlBlaster::util::qos::StatusQosFactory statusQosFactory_; 00050 mutable org::xmlBlaster::util::key::MsgKeyFactory msgKeyFactory_; 00051 mutable org::xmlBlaster::util::qos::MsgQosFactory msgQosFactory_; 00052 org::xmlBlaster::util::thread::Mutex accessMutex_; 00053 00054 public: 00055 SQLiteQueuePlugin(org::xmlBlaster::util::Global& global, const org::xmlBlaster::util::qos::storage::ClientQueueProperty& property); 00056 00060 virtual ~SQLiteQueuePlugin(); 00061 00065 org::xmlBlaster::util::I_Log& getLog() const { return log_; } 00066 00074 void put(const MsgQueueEntry &entry); 00075 00082 const std::vector<EntryType> peekWithSamePriority(long maxNumOfEntries=-1, long maxNumOfBytes=-1) const; 00083 00088 long randomRemove(const std::vector<EntryType>::const_iterator &start, const std::vector<EntryType>::const_iterator &end); 00089 00094 long getNumOfEntries() const; 00095 00100 long getMaxNumOfEntries() const; 00101 00109 int64_t getNumOfBytes() const; 00110 00115 int64_t getMaxNumOfBytes() const; 00116 00120 void clear(); 00121 00125 bool empty() const; 00126 00130 org::xmlBlaster::util::XmlBlasterException convertFromQueueException(const ::ExceptionStruct *ex) const; 00131 00138 static void parseEmbeddedType(const std::string& embeddedType, std::string &type, std::string &methodName); 00139 00140 static std::string usage(); 00141 00147 std::string getType() { static std::string type = "SQLite"; return type; } 00148 00154 std::string getVersion() { static std::string version = "1.0"; return version; } 00155 00156 void destroy(); 00157 }; 00158 00159 }}}} // namespace 00160 00161 #endif 00162