qpid/client/MessageReplayTracker.h Source File

Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET | Apache Qpid Documentation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

qpid/client/MessageReplayTracker.h
Go to the documentation of this file.

    00001 #ifndef QPID_CLIENT_MESSAGEREPLAYTRACKER_H
    00002 #define QPID_CLIENT_MESSAGEREPLAYTRACKER_H
    00003
    00004 /*
    00005  *
    00006  * Licensed to the Apache Software Foundation (ASF) under one
    00007  * or more contributor license agreements.  See the NOTICE file
    00008  * distributed with this work for additional information
    00009  * regarding copyright ownership.  The ASF licenses this file
    00010  * to you under the Apache License, Version 2.0 (the
    00011  * "License"); you may not use this file except in compliance
    00012  * with the License.  You may obtain a copy of the License at
    00013  *
    00014  *   http://www.apache.org/licenses/LICENSE-2.0
    00015  *
    00016  * Unless required by applicable law or agreed to in writing,
    00017  * software distributed under the License is distributed on an
    00018  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    00019  * KIND, either express or implied.  See the License for the
    00020  * specific language governing permissions and limitations
    00021  * under the License.
    00022  *
    00023  */
    00024 #include "qpid/client/AsyncSession.h"
    00025 #include "qpid/client/Message.h"
    00026 #include "qpid/client/ClientImportExport.h"
    00027 #include <list>
    00028 #include <string>
    00029
    00030 namespace qpid {
    00031 namespace client {
    00032
    00037 class QPID_CLIENT_CLASS_EXTERN MessageReplayTracker
    00038 {
    00039   public:
    00040     QPID_CLIENT_EXTERN MessageReplayTracker(uint flushInterval);
    00041     QPID_CLIENT_EXTERN void send(const Message& message, const std::string& destination = "");
    00042     QPID_CLIENT_EXTERN void init(AsyncSession session);
    00043     QPID_CLIENT_EXTERN void replay(AsyncSession session);
    00044     QPID_CLIENT_EXTERN void setFlushInterval(uint interval);
    00045     QPID_CLIENT_EXTERN uint getFlushInterval();
    00046     QPID_CLIENT_EXTERN void checkCompletion();
    00047
    00048     template <class F> void foreach(F& f) {
    00049         for (std::list<ReplayRecord>::const_iterator i = buffer.begin(); i != buffer.end(); i++) {
    00050             f(i->message);
    00051         }
    00052     }
    00053
    00054   private:
    00055     struct ReplayRecord
    00056     {
    00057         Completion status;
    00058         Message message;
    00059         std::string destination;
    00060
    00061         ReplayRecord(const Message& message, const std::string& destination);
    00062         void send(MessageReplayTracker&);
    00063         bool isComplete();
    00064     };
    00065
    00066     AsyncSession session;
    00067     uint flushInterval;
    00068     uint count;
    00069     std::list<ReplayRecord> buffer;
    00070 };
    00071 }} // namespace qpid::client
    00072
    00073 #endif