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 2015/06/04 15:52:24 UTC
[3/4] qpid-proton git commit: PROTON-897: Enhanced the Ruby
nonblocking_recv.rb example
PROTON-897: Enhanced the Ruby nonblocking_recv.rb example
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/b49e5185
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/b49e5185
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/b49e5185
Branch: refs/heads/master
Commit: b49e5185c3ffe4a935ba51e4ce4a0e6f5f3ec172
Parents: 267072d
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Thu Jun 4 08:29:09 2015 -0400
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 4 08:29:09 2015 -0400
----------------------------------------------------------------------
examples/ruby/messenger/nonblocking_recv.rb | 34 +++++++++++++++---------
1 file changed, 21 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/b49e5185/examples/ruby/messenger/nonblocking_recv.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/messenger/nonblocking_recv.rb b/examples/ruby/messenger/nonblocking_recv.rb
index d1fa854..2868b52 100644
--- a/examples/ruby/messenger/nonblocking_recv.rb
+++ b/examples/ruby/messenger/nonblocking_recv.rb
@@ -20,6 +20,14 @@
require 'qpid_proton'
require 'optparse'
+Thread.new do
+ print "This is a side thread:\n"
+ loop do
+ print "The time is now #{Time.new.strftime('%I:%M:%S')}.\n"
+ sleep 1
+ end
+end
+
addresses = []
OptionParser.new do |opts|
@@ -37,8 +45,8 @@ messenger.passive = true
begin
messenger.start
rescue ProtonError => error
- puts "ERROR: #{error.message}"
- puts error.backtrace.join("\n")
+ print "ERROR: #{error.message}\n"
+ print error.backtrace.join("\n")
exit
end
@@ -46,7 +54,7 @@ addresses.each do |address|
begin
messenger.subscribe(address)
rescue Qpid::Proton::ProtonError => error
- puts "ERROR: #{error.message}"
+ print "ERROR: #{error.message}\n"
exit
end
end
@@ -102,7 +110,7 @@ loop do
begin
messenger.receive(10)
rescue Qpid::Proton::ProtonError => error
- puts "ERROR: #{error.message}"
+ print "ERROR: #{error.message}\n"
exit
end
@@ -110,24 +118,24 @@ loop do
begin
messenger.get(msg)
rescue Qpid::Proton::Error => error
- puts "ERROR: #{error.message}"
+ print "ERROR: #{error.message}\n"
exit
end
- puts "Address: #{msg.address}"
+ print "Address: #{msg.address}\n"
subject = msg.subject || "(no subject)"
- puts "Subject: #{subject}"
- puts "Body: #{msg.body}"
- puts "Properties: #{msg.properties}"
- puts "Instructions: #{msg.instructions}"
- puts "Annotations: #{msg.annotations}"
+ print "Subject: #{subject}\n"
+ print "Body: #{msg.body}\n"
+ print "Properties: #{msg.properties}\n"
+ print "Instructions: #{msg.instructions}\n"
+ print "Annotations: #{msg.annotations}\n"
if msg.reply_to
- puts "=== Sending a reply to #{msg.reply_to}"
+ print "=== Sending a reply to #{msg.reply_to}\n"
reply = Qpid::Proton::Message.new
reply.address = msg.reply_to
reply.subject = "RE: #{msg.subject}"
- reply.content = "Thanks for the message!"
+ reply.body = "Thanks for the message!"
messenger.put(reply)
messenger.send
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org