diff options
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; |