summaryrefslogtreecommitdiff
path: root/qpid/cpp/examples/messaging
diff options
context:
space:
mode:
authorDarryl L. Pierce <mcpierce@apache.org>2013-09-11 21:13:06 +0000
committerDarryl L. Pierce <mcpierce@apache.org>2013-09-11 21:13:06 +0000
commit22b2a9a49eff4901fae0ef4987559aec59b4f683 (patch)
tree4d6e9f8340f5b9fab1cba746170b35c0b1e63a59 /qpid/cpp/examples/messaging
parent4fe2d26d1ab8343a8bde3707fd2676fd6f6f5c98 (diff)
downloadqpid-python-22b2a9a49eff4901fae0ef4987559aec59b4f683.tar.gz
QPID-5133: Add option to the spout examples to enable durable messages
Each of the examples (C++, Ruby, Perl, Python) now have a command line option to set the durable flag on messages sent. This allows for experimenting with message persistence. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1522042 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/examples/messaging')
-rw-r--r--qpid/cpp/examples/messaging/spout.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/qpid/cpp/examples/messaging/spout.cpp b/qpid/cpp/examples/messaging/spout.cpp
index 9c463d10b1..d3451c084b 100644
--- a/qpid/cpp/examples/messaging/spout.cpp
+++ b/qpid/cpp/examples/messaging/spout.cpp
@@ -43,6 +43,7 @@ struct Options : OptionParser
std::string url;
std::string address;
int timeout;
+ bool durable;
int count;
std::string id;
std::string replyto;
@@ -55,10 +56,12 @@ struct Options : OptionParser
: OptionParser("Usage: spout [OPTIONS] ADDRESS", "Send messages to the specified address"),
url("127.0.0.1"),
timeout(0),
- count(1)
+ count(1),
+ durable(false)
{
add("broker,b", url, "url of broker to connect to");
add("timeout,t", timeout, "exit after the specified time");
+ add("durable,d", durable, "make the message durable (def. transient)");
add("count,c", count, "stop after count messages have been sent, zero disables");
add("id,i", id, "use the supplied id instead of generating one");
add("reply-to", replyto, "specify reply-to address");
@@ -127,6 +130,11 @@ struct Options : OptionParser
return true;
}
}
+
+ bool isDurable() const
+ {
+ return durable;
+ }
};
@@ -141,6 +149,7 @@ int main(int argc, char** argv)
Sender sender = session.createSender(options.address);
Message message;
+ message.setDurable(options.isDurable());
options.setProperties(message);
Variant& obj = message.getContentObject();
if (options.entries.size()) {