You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by mc...@apache.org on 2013/09/11 23:13:06 UTC
svn commit: r1522042 - in /qpid/trunk/qpid:
cpp/bindings/qpid/examples/perl/spout.pl
cpp/bindings/qpid/ruby/examples/spout.rb cpp/examples/messaging/spout.cpp
python/examples/api/spout
Author: mcpierce
Date: Wed Sep 11 21:13:06 2013
New Revision: 1522042
URL: http://svn.apache.org/r1522042
Log:
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.
Modified:
qpid/trunk/qpid/cpp/bindings/qpid/examples/perl/spout.pl
qpid/trunk/qpid/cpp/bindings/qpid/ruby/examples/spout.rb
qpid/trunk/qpid/cpp/examples/messaging/spout.cpp
qpid/trunk/qpid/python/examples/api/spout
Modified: qpid/trunk/qpid/cpp/bindings/qpid/examples/perl/spout.pl
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qpid/examples/perl/spout.pl?rev=1522042&r1=1522041&r2=1522042&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qpid/examples/perl/spout.pl (original)
+++ qpid/trunk/qpid/cpp/bindings/qpid/examples/perl/spout.pl Wed Sep 11 21:13:06 2013
@@ -28,6 +28,7 @@ use Time::Local;
my $url = "127.0.0.1";
my $timeout = 0;
my $count = 1;
+my $durable = 0;
my $id = "";
my $replyto = "";
my @properties;
@@ -41,6 +42,7 @@ my $result = GetOptions(
"broker|b=s" => \$url,
"timeout|t=i" => \$timeout,
"count|c=i" => \$count,
+ "durable|d" => \$durable,
"id|i=s" => \$id,
"replyto=s" => \$replyto,
"property|p=s@" => \@properties,
@@ -96,6 +98,9 @@ eval {
$message->set_content_type("text/plain");
}
+ # set durable flag
+ $message->set_durable($durable);
+
# if a reply-to address was supplied, then create a receiver from the
# session and wait for a response to be sent
my $receiver;
Modified: qpid/trunk/qpid/cpp/bindings/qpid/ruby/examples/spout.rb
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/bindings/qpid/ruby/examples/spout.rb?rev=1522042&r1=1522041&r2=1522042&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/bindings/qpid/ruby/examples/spout.rb (original)
+++ qpid/trunk/qpid/cpp/bindings/qpid/ruby/examples/spout.rb Wed Sep 11 21:13:06 2013
@@ -26,6 +26,7 @@ options = {
:broker => "127.0.0.1",
:address => "",
:timeout => 0,
+ :durable => false,
:count => 1,
:properties => {},
:content => nil,
@@ -51,6 +52,11 @@ opts = OptionParser.new do |opts|
options[:timeout] = Qpid::Messaging::Duration.new timeout * 1000
end
+ opts.on("-d", "--durable",
+ "make the message durable (def. #{options[:durable]})") do
+ options[:durable] = true
+ end
+
opts.on("-c", "--count VALUE", Integer,
"stop after count messages have been sent, zero disables") do |count|
options[:count] = count
@@ -135,6 +141,7 @@ options[:properties].each_key {|key| mes
elsif options[:content]
message.content = options[:content]
end
+ message.durable = options[:durable]
message.content = options[:content] unless options[:content].nil?
message.properties["spout-id"] = "#{count}"
message.reply_to = options[:replyto] unless options[:replyto].nil? || options[:replyto].empty?
Modified: qpid/trunk/qpid/cpp/examples/messaging/spout.cpp
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/cpp/examples/messaging/spout.cpp?rev=1522042&r1=1522041&r2=1522042&view=diff
==============================================================================
--- qpid/trunk/qpid/cpp/examples/messaging/spout.cpp (original)
+++ qpid/trunk/qpid/cpp/examples/messaging/spout.cpp Wed Sep 11 21:13:06 2013
@@ -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()) {
Modified: qpid/trunk/qpid/python/examples/api/spout
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/examples/api/spout?rev=1522042&r1=1522041&r2=1522042&view=diff
==============================================================================
--- qpid/trunk/qpid/python/examples/api/spout (original)
+++ qpid/trunk/qpid/python/examples/api/spout Wed Sep 11 21:13:06 2013
@@ -45,6 +45,8 @@ parser.add_option("-l", "--reconnect-lim
help="maximum number of reconnect attempts")
parser.add_option("-c", "--count", type="int", default=1,
help="stop after count messages have been sent, zero disables (default %default)")
+parser.add_option("-d", "--durable", action="store_true",
+ help="make the message persistent")
parser.add_option("-t", "--timeout", type="float", default=None,
help="exit after the specified time")
parser.add_option("-I", "--id", help="use the supplied id instead of generating one")
@@ -111,6 +113,8 @@ try:
msg = Message(subject=opts.subject,
reply_to=opts.reply_to,
content=content)
+ if opts.durable:
+ msg.durable = True
if content_type is not None:
msg.content_type = content_type
msg.properties["spout-id"] = "%s:%s" % (spout_id, count)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org