20#define RESIPROCATE_SUBSYSTEM Subsystem::REPRO
22#ifndef DISABLE_BERKELEYDB_USE
33 dbenv->txn_begin(NULL, &
mDbTxn, 0);
50 catch(DbException&) {}
51 catch(std::exception&) {}
77 void init(Db* db, DbTxn* t)
80 db->cursor(t, &
mDbc, 0);
97 catch(DbException&) {}
98 catch(std::exception&) {}
110#ifndef DISABLE_BERKELEYDB_USE
115 mRecoveryNeeded(false)
121#ifndef DISABLE_BERKELEYDB_USE
128 catch(DbException&) {}
129 catch(std::exception&) {}
138 catch(DbException&) {}
139 catch(std::exception&) {}
147#ifndef DISABLE_BERKELEYDB_USE
151 set_flags(DB_CDB_ALLDB, 1);
156 set_flags(DB_TXN_NOSYNC, 0);
160 set_flags(DB_TXN_NOSYNC, 1);
179 open(homeDir.
c_str(),
190 mDb =
new Db(
this, 0);
193 mDb->set_flags(DB_RENUMBER);
206 catch(DbException& e)
208 if(e.get_errno() == DB_RUNRECOVERY)
212 WarningLog( <<
"PersistentMessageQueue::init - DBException: " << e.what());
214 catch(std::exception& e)
216 WarningLog( <<
"PersistentMessageQueue::init - std::exception: " << e.what());
220 WarningLog( <<
"PersistentMessageQueue::init - unknown exception");
235#ifndef DISABLE_BERKELEYDB_USE
241 transaction.
init(
this);
245 Dbt val((
void*)data.
c_str(), (u_int32_t)data.
size());
246 Dbt key((
void*)&recno,
sizeof(recno));
248 key.set_ulen(
sizeof(recno));
249 key.set_flags(DB_DBT_USERMEM);
251 res =
mDb->put(transaction.
mDbTxn, &key, &val, DB_APPEND);
259 WarningLog( <<
"PersistentMessageEnqueue::push - put failed: " << db_strerror(res));
263 catch(DbException& e)
265 if(e.get_errno() == DB_RUNRECOVERY)
269 WarningLog( <<
"PersistentMessageEnqueue::push - DBException: " << e.what());
271 catch(std::exception& e)
273 WarningLog( <<
"PersistentMessageEnqueue::push - std::exception: " << e.what());
277 WarningLog( <<
"PersistentMessageEnqueue::push - unknown exception");
288#ifndef DISABLE_BERKELEYDB_USE
302 transaction.
init(
this);
307 db_recno_t recno = 0;
308 Dbt key((
void*)&recno,
sizeof(recno));
310 for(
size_t i = 0; i < numRecords; i ++ )
312 int get_res = cursor.
mDbc->get(&key, &val, DB_NEXT | (autoCommit ? DB_RMW : 0));
316 records.push_back(
Data((
const char *)val.get_data(), val.get_size()));
335 mNumRecords = records.size();
339 catch(DbException& e)
341 if(e.get_errno() == DB_RUNRECOVERY)
345 WarningLog( <<
"PersistentMessageDequeue::pop - DBException: " << e.what());
348 catch(std::exception& e)
350 WarningLog( <<
"PersistentMessageDequeue::pop - std::exception: " << e.what());
355 WarningLog( <<
"PersistentMessageDequeue::pop - unknown exception");
365#ifndef DISABLE_BERKELEYDB_USE
377 transaction.
init(
this);
381 db_recno_t recno = 0;
382 Dbt key((
void*)&recno,
sizeof(recno));
384 for(
size_t i = 0; i < mNumRecords; i++)
386 int get_res = cursor.
mDbc->get(&key, &val, DB_NEXT | DB_RMW);
403 catch(DbException& e)
405 if(e.get_errno() == DB_RUNRECOVERY)
409 WarningLog( <<
"PersistentMessageDequeue::commit - DBException: " << e.what());
411 catch(std::exception& e)
413 WarningLog( <<
"PersistentMessageDequeue::commit - std::exception: " << e.what());
417 WarningLog( <<
"PersistentMessageDequeue::commit - unknown exception");
#define WarningLog(args_)
bool pop(size_t numRecords, std::vector< resip::Data > &records, bool autoCommit)
bool push(const resip::Data &data)
virtual ~PersistentMessageQueue()
PersistentMessageQueue(const resip::Data &baseDir)
bool init(bool sync, const resip::Data &queueName)
An alternative to std::string, encapsulates an arbitrary buffer of bytes.
const char * c_str() const
Returns a null-terminated string representing.
bool empty() const noexcept
Checks whether the Data is empty.
size_type size() const noexcept
Returns the number of bytes in this Data.
bool postfix(const Data &post) const noexcept
Returns true if this Data ends with the bytes indicated by the passed-in Data.
This Class is used to implement a primitive form of RPC using loose XML formatting.
dcm! – add UnusedChecking(_enum) below;
void init(Db *db, DbTxn *t)