diff options
author | Alan Conway <aconway@apache.org> | 2008-10-31 15:08:00 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2008-10-31 15:08:00 +0000 |
commit | 79323867dae1ad7b0d00e4055e506749236d9bf1 (patch) | |
tree | 7a072a6ad8f9b81cf5984a61d2e9cdfbb26d1d89 /cpp | |
parent | 2ff919b2bf8623b6bf542e589aae4c05c403a009 (diff) | |
download | qpid-python-79323867dae1ad7b0d00e4055e506749236d9bf1.tar.gz |
Added return Message overload of SubscriptionManager get().
Fixed compile error in broker/Vhost.cpp
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@709440 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/src/qpid/broker/Vhost.cpp | 4 | ||||
-rw-r--r-- | cpp/src/qpid/client/LocalQueue.h | 6 | ||||
-rw-r--r-- | cpp/src/qpid/client/SubscriptionManager.cpp | 7 | ||||
-rw-r--r-- | cpp/src/qpid/client/SubscriptionManager.h | 8 | ||||
-rw-r--r-- | cpp/src/tests/cluster_test.cpp | 9 |
5 files changed, 24 insertions, 10 deletions
diff --git a/cpp/src/qpid/broker/Vhost.cpp b/cpp/src/qpid/broker/Vhost.cpp index 537d2b4e29..c5bb6c5104 100644 --- a/cpp/src/qpid/broker/Vhost.cpp +++ b/cpp/src/qpid/broker/Vhost.cpp @@ -24,7 +24,9 @@ using namespace qpid::broker; using qpid::management::ManagementAgent; namespace _qmf = qmf::org::apache::qpid::broker; -class qpid::management::Manageable; +namespace qpid { namespace management { +class Manageable; +}} Vhost::Vhost (qpid::management::Manageable* parentBroker) : mgmtObject(0) { diff --git a/cpp/src/qpid/client/LocalQueue.h b/cpp/src/qpid/client/LocalQueue.h index 3be2293810..2b878b2939 100644 --- a/cpp/src/qpid/client/LocalQueue.h +++ b/cpp/src/qpid/client/LocalQueue.h @@ -58,11 +58,13 @@ class LocalQueue { /** Get the next message off the local queue, or wait up to the timeout * for message from the broker queue. - *@exception ClosedException if subscription is closed or timeout exceeded. + *@param timeout wait up this timeout for a message to appear. + *@return message from the queue. + *@throw ClosedException if subscription is closed or timeout exceeded. */ Message get(sys::Duration timeout=sys::TIME_INFINITE); - /** Synonym for get(). */ + /** Synonym for get() */ Message pop(sys::Duration timeout=sys::TIME_INFINITE); /** Return true if local queue is empty. */ diff --git a/cpp/src/qpid/client/SubscriptionManager.cpp b/cpp/src/qpid/client/SubscriptionManager.cpp index 350fd86aa6..6fa1973b9d 100644 --- a/cpp/src/qpid/client/SubscriptionManager.cpp +++ b/cpp/src/qpid/client/SubscriptionManager.cpp @@ -107,6 +107,13 @@ bool SubscriptionManager::get(Message& result, const std::string& queue, sys::Du return lq.get(result, 0); } +Message SubscriptionManager::get(const std::string& queue, sys::Duration timeout) { + Message result; + if (!get(result, queue, timeout)) + throw Exception("Timed out waiting for a message"); + return result; +} + Session SubscriptionManager::getSession() const { return session; } Subscription SubscriptionManager::getSubscription(const std::string& name) const { diff --git a/cpp/src/qpid/client/SubscriptionManager.h b/cpp/src/qpid/client/SubscriptionManager.h index 46394808f4..393349a6af 100644 --- a/cpp/src/qpid/client/SubscriptionManager.h +++ b/cpp/src/qpid/client/SubscriptionManager.h @@ -120,12 +120,18 @@ class SubscriptionManager : public sys::Runnable /** Get a single message from a queue. *@param result is set to the message from the queue. - *@ *@param timeout wait up this timeout for a message to appear. *@return true if result was set, false if no message available after timeout. */ bool get(Message& result, const std::string& queue, sys::Duration timeout=0); + /** Get a single message from a queue. + *@param timeout wait up this timeout for a message to appear. + *@return message from the queue. + *@throw Exception if the timeout is exceeded. + */ + Message get(const std::string& queue, sys::Duration timeout=sys::TIME_INFINITE); + /** Get a subscription by name. *@throw Exception if not found. */ diff --git a/cpp/src/tests/cluster_test.cpp b/cpp/src/tests/cluster_test.cpp index 887a0716e7..63bd31ea1b 100644 --- a/cpp/src/tests/cluster_test.cpp +++ b/cpp/src/tests/cluster_test.cpp @@ -264,12 +264,9 @@ QPID_AUTO_TEST_CASE(testUnacked) { BOOST_CHECK_EQUAL(c1.session.queueQuery("q1").getMessageCount(), 1u); BOOST_CHECK_EQUAL(c1.session.queueQuery("q2").getMessageCount(), 2u); - BOOST_CHECK(c1.subs.get(m, "q1", TIME_SEC)); - BOOST_CHECK_EQUAL(m.getData(), "11"); - BOOST_CHECK(c1.subs.get(m, "q2", TIME_SEC)); - BOOST_CHECK_EQUAL(m.getData(), "21"); - BOOST_CHECK(c1.subs.get(m, "q2", TIME_SEC)); - BOOST_CHECK_EQUAL(m.getData(), "22"); + BOOST_CHECK_EQUAL(c1.subs.get("q1", TIME_SEC).getData(), "11"); + BOOST_CHECK_EQUAL(c1.subs.get("q2", TIME_SEC).getData(), "21"); + BOOST_CHECK_EQUAL(c1.subs.get("q2", TIME_SEC).getData(), "22"); } QPID_AUTO_TEST_CASE_EXPECTED_FAILURES(testDumpTxState, 1) { |