diff options
author | Michael Goulish <mgoulish@apache.org> | 2009-09-09 15:30:12 +0000 |
---|---|---|
committer | Michael Goulish <mgoulish@apache.org> | 2009-09-09 15:30:12 +0000 |
commit | f8830aa4cc47c6cbeefecde841803c535916e09e (patch) | |
tree | 754edfd041c99ca68631f1fee9887f82b8dcab2d /cpp/src | |
parent | 92e7e8045c6d3812dcf22a4490bfae663f9e2785 (diff) | |
download | qpid-python-f8830aa4cc47c6cbeefecde841803c535916e09e.tar.gz |
( mgoulish checking in changes for gsim )
add ttl option for messages.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@812995 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/tests/sender.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/cpp/src/tests/sender.cpp b/cpp/src/tests/sender.cpp index 311de2e5f8..c1c3f2688f 100644 --- a/cpp/src/tests/sender.cpp +++ b/cpp/src/tests/sender.cpp @@ -43,16 +43,18 @@ struct Args : public qpid::TestOptions string key; uint sendEos; bool durable; + uint ttl; string lvqMatchValue; string lvqMatchFile; - Args() : key("test-queue"), sendEos(0), durable(false) + Args() : key("test-queue"), sendEos(0), durable(false), ttl(0) { addOptions() ("exchange", qpid::optValue(destination, "EXCHANGE"), "Exchange to send messages to") ("routing-key", qpid::optValue(key, "KEY"), "Routing key to add to messages") ("send-eos", qpid::optValue(sendEos, "N"), "Send N EOS messages to mark end of input") ("durable", qpid::optValue(durable, "true|false"), "Mark messages as durable.") + ("ttl", qpid::optValue(ttl, "msecs"), "Time-to-live for messages, in milliseconds") ("lvq-match-value", qpid::optValue(lvqMatchValue, "KEY"), "The value to set for the LVQ match key property") ("lvq-match-file", qpid::optValue(lvqMatchFile, "FILE"), "A file containing values to set for the LVQ match key property"); } @@ -63,8 +65,7 @@ const string EOS("eos"); class Sender : public FailoverManager::Command { public: - Sender(const std::string& destination, const std::string& key, uint sendEos, bool durable, - const std::string& lvqMatchValue, const std::string& lvqMatchFile); + Sender(const std::string& destination, const std::string& key, uint sendEos, bool durable, uint ttl, const std::string& lvqMatchValue, const std::string& lvqMatchFile); void execute(AsyncSession& session, bool isRetry); private: const std::string destination; @@ -75,14 +76,17 @@ class Sender : public FailoverManager::Command std::ifstream lvqMatchValues; }; -Sender::Sender(const std::string& dest, const std::string& key, uint eos, bool durable, - const std::string& lvqMatchValue, const std::string& lvqMatchFile) : +Sender::Sender(const std::string& dest, const std::string& key, uint eos, bool durable, uint ttl, const std::string& lvqMatchValue, const std::string& lvqMatchFile) : destination(dest), sender(10), message("", key), sendEos(eos), sent(0) , lvqMatchValues(lvqMatchFile.c_str()) { if (durable){ message.getDeliveryProperties().setDeliveryMode(framing::PERSISTENT); } + if (ttl) { + message.getDeliveryProperties().setTtl(ttl); + } + if (!lvqMatchValue.empty()) { message.getHeaders().setString(QueueOptions::strLVQMatchProperty, lvqMatchValue); } @@ -114,7 +118,7 @@ int main(int argc, char ** argv) try { opts.parse(argc, argv); FailoverManager connection(opts.con); - Sender sender(opts.destination, opts.key, opts.sendEos, opts.durable, opts.lvqMatchValue, opts.lvqMatchFile); + Sender sender(opts.destination, opts.key, opts.sendEos, opts.durable, opts.ttl, opts.lvqMatchValue, opts.lvqMatchFile); connection.execute(sender); connection.close(); return 0; |