diff options
author | Gordon Sim <gsim@apache.org> | 2009-02-26 18:12:21 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2009-02-26 18:12:21 +0000 |
commit | 9578058fc27c166a3021f38abf1f6a6c7c8f6b7a (patch) | |
tree | 7f64a2badd772b79c4250126785c9a8ad4f136d0 /cpp/src/tests/receiver.cpp | |
parent | e6f1a9404d4544e872a40c598f86e1d442cc41db (diff) | |
download | qpid-python-9578058fc27c166a3021f38abf1f6a6c7c8f6b7a.tar.gz |
Add browse option, useful for ad-hoc testing.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@748252 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/tests/receiver.cpp')
-rw-r--r-- | cpp/src/tests/receiver.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/cpp/src/tests/receiver.cpp b/cpp/src/tests/receiver.cpp index 1ecaece51e..2ea2927b8c 100644 --- a/cpp/src/tests/receiver.cpp +++ b/cpp/src/tests/receiver.cpp @@ -23,7 +23,7 @@ #include <qpid/client/Session.h> #include <qpid/client/Message.h> #include <qpid/client/SubscriptionManager.h> -#include <qpid/client/SubscriptionManager.h> +#include <qpid/client/SubscriptionSettings.h> #include "TestOptions.h" #include <iostream> @@ -43,15 +43,17 @@ struct Args : public qpid::TestOptions bool ignoreDuplicates; uint creditWindow; uint ackFrequency; + bool browse; - Args() : queue("test-queue"), messages(0), ignoreDuplicates(false), creditWindow(0), ackFrequency(1) + Args() : queue("test-queue"), messages(0), ignoreDuplicates(false), creditWindow(0), ackFrequency(1), browse(false) { addOptions() ("queue", qpid::optValue(queue, "QUEUE NAME"), "Queue from which to request messages") ("messages", qpid::optValue(messages, "N"), "Number of messages to receive; 0 means receive indefinitely") ("ignore-duplicates", qpid::optValue(ignoreDuplicates), "Detect and ignore duplicates (by checking 'sn' header)") ("credit-window", qpid::optValue(creditWindow, "N"), "Credit window (0 implies infinite window)") - ("ack-frequency", qpid::optValue(ackFrequency, "N"), "Ack frequency (0 implies none of the messages will get accepted)"); + ("ack-frequency", qpid::optValue(ackFrequency, "N"), "Ack frequency (0 implies none of the messages will get accepted)") + ("browse", qpid::optValue(browse), "Browse rather than consuming"); } }; @@ -60,7 +62,7 @@ const string EOS("eos"); class Receiver : public MessageListener, public FailoverManager::Command { public: - Receiver(const string& queue, uint messages, bool ignoreDuplicates, uint creditWindow, uint ackFrequency); + Receiver(const string& queue, uint messages, bool ignoreDuplicates, uint creditWindow, uint ackFrequency, bool browse); void received(Message& message); void execute(AsyncSession& session, bool isRetry); private: @@ -75,9 +77,10 @@ class Receiver : public MessageListener, public FailoverManager::Command bool isDuplicate(Message& message); }; -Receiver::Receiver(const string& q, uint messages, bool ignoreDuplicates, uint creditWindow, uint ackFrequency) : +Receiver::Receiver(const string& q, uint messages, bool ignoreDuplicates, uint creditWindow, uint ackFrequency, bool browse) : queue(q), count(messages), skipDups(ignoreDuplicates), processed(0), lastSn(0) { + if (browse) settings.acquireMode = ACQUIRE_MODE_NOT_ACQUIRED; if (creditWindow) settings.flowControl = FlowControl::messageWindow(creditWindow); settings.autoAck = ackFrequency; } @@ -115,7 +118,7 @@ int main(int argc, char ** argv) try { opts.parse(argc, argv); FailoverManager connection(opts.con); - Receiver receiver(opts.queue, opts.messages, opts.ignoreDuplicates, opts.creditWindow, opts.ackFrequency); + Receiver receiver(opts.queue, opts.messages, opts.ignoreDuplicates, opts.creditWindow, opts.ackFrequency, opts.browse); connection.execute(receiver); connection.close(); return 0; |