diff options
author | Stephen D. Huston <shuston@apache.org> | 2009-04-23 21:06:35 +0000 |
---|---|---|
committer | Stephen D. Huston <shuston@apache.org> | 2009-04-23 21:06:35 +0000 |
commit | a7259adba14345898e78b483b7620340ffa5cfc5 (patch) | |
tree | e8d26c0981a666442ad4aa2fff5ddb87c5ce5866 /qpid/cpp/src/tests/client_test.cpp | |
parent | 8d32b03448e8e1ba6319fc0ac484d0ab54b29b38 (diff) | |
download | qpid-python-cmake.tar.gz |
Merge in trunk changes from r758432:768028cmake
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/cmake@768053 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/tests/client_test.cpp')
-rw-r--r-- | qpid/cpp/src/tests/client_test.cpp | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/qpid/cpp/src/tests/client_test.cpp b/qpid/cpp/src/tests/client_test.cpp index 204c2c4b71..05b42f620c 100644 --- a/qpid/cpp/src/tests/client_test.cpp +++ b/qpid/cpp/src/tests/client_test.cpp @@ -32,8 +32,8 @@ #include "qpid/client/Connection.h" #include "qpid/client/Message.h" #include "qpid/client/Session.h" -#include "qpid/framing/FrameSet.h" -#include "qpid/framing/all_method_bodies.h" +#include "qpid/client/SubscriptionManager.h" + using namespace qpid; using namespace qpid::client; @@ -113,35 +113,18 @@ int main(int argc, char** argv) session.messageTransfer(arg::destination="MyExchange", arg::content=msgOut, arg::acceptMode=1); if (opts.verbose) print("Published message: ", msgOut); - //subscribe to the queue, add sufficient credit and then get - //incoming 'frameset', check that its a message transfer and - //then convert it to a message (see Dispatcher and - //SubscriptionManager utilties for common reusable patterns at - //a higher level) - session.messageSubscribe(arg::queue="MyQueue", arg::destination="MyId"); - session.messageFlow(arg::destination="MyId", arg::unit=0, arg::value=1); //credit for one message - session.messageFlow(arg::destination="MyId", arg::unit=1, arg::value=0xFFFFFFFF); //credit for infinite bytes - if (opts.verbose) std::cout << "Subscribed to queue." << std::endl; - FrameSet::shared_ptr incoming = session.get(); - if (incoming->isA<MessageTransferBody>()) { - Message msgIn(*incoming); - if (msgIn.getData() == msgOut.getData()) { - if (opts.verbose) std::cout << "Received the exepected message." << std::endl; - session.messageAccept(SequenceSet(msgIn.getId())); - session.markCompleted(msgIn.getId(), true, true); - } else { - print("Received an unexepected message: ", msgIn); - } - } else { - throw Exception("Unexpected command received"); - } - + // Using the SubscriptionManager, get the message from the queue. + SubscriptionManager subs(session); + Message msgIn = subs.get("MyQueue"); + if (msgIn.getData() == msgOut.getData()) + if (opts.verbose) std::cout << "Received the exepected message." << std::endl; + //close the session & connection session.close(); if (opts.verbose) std::cout << "Closed session." << std::endl; connection.close(); if (opts.verbose) std::cout << "Closed connection." << std::endl; - return 0; + return 0; } catch(const std::exception& e) { std::cout << e.what() << std::endl; } |