示例#1
0
    void enqueue(TransactionContext* tx,
                 const boost::intrusive_ptr<PersistableMessage>& pmsg,
                 const PersistableQueue& queue)
    {
        ostringstream o;
        string data = getContent(pmsg);
        o << "<enqueue " << queue.getName() << " " << data;
        if (tx) o << " tx=" << getId(*tx);
        o << ">";
        log(o.str());

        // Dump the message if there is a dump file.
        if (dump.get()) {
            *dump << "Message(" << data.size() << "): " << data << endl;
        }
        string logPrefix = "TestStore "+name+": ";
        Action action(data);
        bool doComplete = true;
        if (action.index && action.executeIn(name)) {
            switch (action.index) {

              case Action::THROW:
                throw Exception(logPrefix + data);
                break;

              case Action::DELAY: {
                  if (action.args.empty()) {
                      QPID_LOG(error, logPrefix << "async-id needs argument: " << data);
                      break;
                  }
                  asyncIds[action.args[0]] = pmsg;
                  QPID_LOG(debug, logPrefix << "delayed completion " << action.args[0]);
                  doComplete = false;
                  break;
              }

              case Action::COMPLETE: {
                  if (action.args.empty()) {
                      QPID_LOG(error, logPrefix << "complete-id needs argument: " << data);
                      break;
                  }
                  AsyncIds::iterator i = asyncIds.find(action.args[0]);
                  if (i != asyncIds.end()) {
                      i->second->enqueueComplete();
                      QPID_LOG(debug, logPrefix << "completed " << action.args[0]);
                      asyncIds.erase(i);
                  } else {
                      QPID_LOG(info, logPrefix << "not found for completion " << action.args[0]);
                  }
                  break;
              }

              default:
                QPID_LOG(error, logPrefix << "unknown action: " << data);
            }
        }
        if (doComplete) pmsg->enqueueComplete();
    }
示例#2
0
文件: test_store.cpp 项目: ncdc/qpid
 void run() {
     qpid::sys::usleep(usecs);
     message->enqueueComplete();
     delete this;
 }