summaryrefslogtreecommitdiff
path: root/qpid/cpp
diff options
context:
space:
mode:
authorDarryl L. Pierce <mcpierce@apache.org>2013-07-12 19:13:58 +0000
committerDarryl L. Pierce <mcpierce@apache.org>2013-07-12 19:13:58 +0000
commit19d1f6373f1f797f915b852a5f398ded59ce8a44 (patch)
treee9bdd10f80cb71175384404d2ac32f73ce7991a0 /qpid/cpp
parent9285cd01da65e5a496a88e5f43a63d69e3a767e9 (diff)
downloadqpid-python-19d1f6373f1f797f915b852a5f398ded59ce8a44.tar.gz
QPID-4834: Fixed how Ruby spout example processes connection options
The argument comes in as a string. It is now processed, the keys and values extracted and put into a proper Hash that is then passed to the Qpid::Messaging::Connection object. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1502660 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp')
-rw-r--r--qpid/cpp/bindings/qpid/ruby/ChangeLog3
-rw-r--r--qpid/cpp/bindings/qpid/ruby/examples/spout.rb25
2 files changed, 26 insertions, 2 deletions
diff --git a/qpid/cpp/bindings/qpid/ruby/ChangeLog b/qpid/cpp/bindings/qpid/ruby/ChangeLog
index b964e33998..f9906c2d51 100644
--- a/qpid/cpp/bindings/qpid/ruby/ChangeLog
+++ b/qpid/cpp/bindings/qpid/ruby/ChangeLog
@@ -1,3 +1,6 @@
+Version 0.26:
+ * QPID-4834: Ruby client examples incorrectly handles '--connection-options' option
+
Version 0.24:
* No language-specific changes.
diff --git a/qpid/cpp/bindings/qpid/ruby/examples/spout.rb b/qpid/cpp/bindings/qpid/ruby/examples/spout.rb
index f7170f146b..ebcf08b7a5 100644
--- a/qpid/cpp/bindings/qpid/ruby/examples/spout.rb
+++ b/qpid/cpp/bindings/qpid/ruby/examples/spout.rb
@@ -85,8 +85,9 @@ opts = OptionParser.new do |opts|
options[:content] = content
end
- opts.on(nil, "--connection-options VALUE",
+ opts.on("--connection-options VALUE",
"connection options string in the form {name1:value1, name2:value2}") do |conopts|
+
options[:connection_options] = conopts
end
end
@@ -100,7 +101,27 @@ end
# now get the non-arg options
options[:address] = ARGV[0] unless ARGV[0].nil?
-connection = Qpid::Messaging::Connection.new :url => options[:broker], :options => options[:connection_options]
+# process the connection options
+unless options[:connection_options].nil?
+ fields = options[:connection_options].gsub(/^{(.*)}$/, '\1')
+ # remove any surrounding braces
+ if /{.*}/ =~ fields
+ fields = fields[1..-2]
+ end
+ # break up the options separated by commas
+ keysvalues = {}
+ fields.split(",").each do |field|
+ if /.+:.+/ =~ field
+ (key, value) = field.split(":")
+ keysvalues[key] = value
+ end
+ end
+ # now store the options
+ options[:connection_options] = keysvalues
+end
+
+connection = Qpid::Messaging::Connection.new(:url => options[:broker],
+ :options => options[:connection_options])
connection.open
session = connection.create_session
sender = session.create_sender options[:address]