summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/broker/QueueEvents.h
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2009-01-15 11:29:38 +0000
committerGordon Sim <gsim@apache.org>2009-01-15 11:29:38 +0000
commite46c3c0a19af0fd659cfe018c34db1c0dfd498c5 (patch)
tree661de23013441445a9b04276fc4b7220906e5d18 /cpp/src/qpid/broker/QueueEvents.h
parent85679201de2448430804ff02d8a47894faf34f49 (diff)
downloadqpid-python-e46c3c0a19af0fd659cfe018c34db1c0dfd498c5.tar.gz
QPID-1567: Initial support for asynchronous queue state replication
* Added QueueEvents class with per broker instance * Modified qpid::broker::Queue to notify QueueEvents of enqueues and dequeues (based on configuration) * Added replication subdir containing two plugins: - an event listener that registers with QueueEvents and creates messages representing received events on a replication queue - a custom exchange type for processing messages of the format created by the listener plugin * Added new option for controlling event generation to qpid::client::QueueOptions * Added new queue option to qpid-config script for the same git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@734674 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/broker/QueueEvents.h')
-rw-r--r--cpp/src/qpid/broker/QueueEvents.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/cpp/src/qpid/broker/QueueEvents.h b/cpp/src/qpid/broker/QueueEvents.h
new file mode 100644
index 0000000000..2ba69e33e6
--- /dev/null
+++ b/cpp/src/qpid/broker/QueueEvents.h
@@ -0,0 +1,77 @@
+#ifndef QPID_BROKER_QUEUEEVENTS_H
+#define QPID_BROKER_QUEUEEVENTS_H
+
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+
+#include "QueuedMessage.h"
+#include "qpid/sys/Mutex.h"
+#include "qpid/sys/PollableQueue.h"
+#include <map>
+#include <string>
+#include <boost/function.hpp>
+
+namespace qpid {
+namespace broker {
+
+/**
+ * Event manager for queue events. Allows queues to indicate when
+ * events have occured; allows listeners to register for notification
+ * of this. The notification happens asynchronously, in a separate
+ * thread.
+ */
+class QueueEvents
+{
+ public:
+ enum EventType {ENQUEUE, DEQUEUE};
+
+ struct Event
+ {
+ EventType type;
+ QueuedMessage msg;
+
+ Event(EventType, const QueuedMessage&);
+ };
+
+ typedef boost::function<void (Event)> EventListener;
+
+ QueueEvents(const boost::shared_ptr<sys::Poller>& poller);
+ ~QueueEvents();
+ void enqueued(const QueuedMessage&);
+ void dequeued(const QueuedMessage&);
+ void registerListener(const std::string& id, const EventListener&);
+ void unregisterListener(const std::string& id);
+ //process all outstanding events
+ void shutdown();
+ private:
+ typedef qpid::sys::PollableQueue<Event> EventQueue;
+ typedef std::map<std::string, EventListener> Listeners;
+
+ EventQueue eventQueue;
+ Listeners listeners;
+ qpid::sys::Mutex lock;//protect listeners from concurrent access
+
+ void handle(EventQueue::Queue& e);
+
+};
+}} // namespace qpid::broker
+
+#endif /*!QPID_BROKER_QUEUEEVENTS_H*/