You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2017/11/07 19:26:47 UTC

[05/10] qpid-proton git commit: PROTON-1064: [ruby] remove obsolete examples

PROTON-1064: [ruby] remove obsolete examples

- make to_native_path available to bindings
- move Container examples to top level
- Update INSTALL.md doc
- Add ruby-docs target to generate docs with yard


Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/3d258158
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/3d258158
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/3d258158

Branch: refs/heads/master
Commit: 3d258158c6e5f95e8a6123a3faddf89772b563ce
Parents: bca7fd1
Author: Alan Conway <ac...@redhat.com>
Authored: Fri Sep 15 10:47:03 2017 -0400
Committer: Alan Conway <ac...@redhat.com>
Committed: Tue Nov 7 13:31:51 2017 -0500

----------------------------------------------------------------------
 INSTALL.md                                      |   6 +-
 examples/ruby/README.md                         | 103 +++++
 examples/ruby/broker.rb                         | 198 ++++++++++
 examples/ruby/client.rb                         |  82 ++++
 examples/ruby/direct_recv.rb                    |  66 ++++
 examples/ruby/direct_send.rb                    |  76 ++++
 examples/ruby/engine_recv.rb                    | 158 --------
 examples/ruby/engine_send.rb                    | 143 -------
 examples/ruby/example_test.rb                   |  41 +-
 examples/ruby/helloworld.rb                     |  73 ++++
 examples/ruby/helloworld_direct.rb              |  74 ++++
 examples/ruby/lib/debugging.rb                  |  26 --
 examples/ruby/lib/driver.rb                     |  69 ----
 examples/ruby/lib/qpid_examples.rb              |  28 --
 examples/ruby/lib/selectable.rb                 | 120 ------
 examples/ruby/lib/send_and_receive.rb           |  90 -----
 examples/ruby/reactor/README.md                 | 103 -----
 examples/ruby/reactor/broker.rb                 | 200 ----------
 examples/ruby/reactor/client.rb                 |  82 ----
 examples/ruby/reactor/direct_recv.rb            |  60 ---
 examples/ruby/reactor/direct_send.rb            |  59 ---
 examples/ruby/reactor/helloworld.rb             |  73 ----
 examples/ruby/reactor/helloworld_direct.rb      |  74 ----
 examples/ruby/reactor/server.rb                 |  76 ----
 examples/ruby/reactor/simple_recv.rb            |  58 ---
 examples/ruby/reactor/simple_send.rb            |  55 ---
 examples/ruby/registry_test.rb                  |  76 ----
 examples/ruby/server.rb                         |  76 ++++
 examples/ruby/simple_recv.rb                    |  69 ++++
 examples/ruby/simple_send.rb                    |  73 ++++
 examples/ruby/wrapper_test.rb                   |  82 ----
 proton-c/CMakeLists.txt                         |  15 +
 proton-c/bindings/ruby/lib/core/message.rb      |  10 +-
 .../bindings/ruby/lib/messenger/messenger.rb    |   2 +
 proton-c/bindings/ruby/spec/messenger_spec.rb   | 393 -------------------
 proton-c/bindings/ruby/tests/test_tools.rb      |   8 +-
 36 files changed, 958 insertions(+), 2039 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/INSTALL.md
----------------------------------------------------------------------
diff --git a/INSTALL.md b/INSTALL.md
index b9482ff..0458bd2 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -49,8 +49,10 @@ language.
     $ yum install php-devel                                  # PHP
     $ yum install perl-devel                                 # Perl
 
-    # Dependencies needed for Python docs
-    $ yum install epydoc
+    # Dependencies needed to generate documentation
+    $ yum install epydoc                                     # Python
+    $ yum install rubygem-yard                               # Ruby
+    $ yum install doxygen                                    # C, C++
 
 The following prerequisites are required to do a full build on
 Debian-based systems (Ubuntu).  If you do not wish to build a given

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/README.md
----------------------------------------------------------------------
diff --git a/examples/ruby/README.md b/examples/ruby/README.md
new file mode 100644
index 0000000..38cc6ba
--- /dev/null
+++ b/examples/ruby/README.md
@@ -0,0 +1,103 @@
+## What Is The Reactor?
+
+A little outside of the scope of this document, but the reactor is an event source for letting an application know about events in the Proton messaging system. With this set of APIs an application can be register handlers that are notified when a connection is created, a message received, or a session closes.
+
+### Handlers
+
+An application creates **handlers**, objects which provide methods through which the reactor notifies the application's components of events and allows them each to handle the ones in which they are interested (see the Chain Of Responsibility design pattern for more on this idea). There are some pre-defined handlers for responding to incoming message events, outgoing message events, data flow and managing the AMQP endpoints. Look in the **Qpid::Proton::Handlers** package for more details on these classes.
+
+## Simple Reactor Examples
+
+### The Broker
+
+The reactor examples come with a sample broker which can be used by other examples and which also works as an example itself. For now we'll just start up the broker example and tell it to listen on port 8888:
+
+````
+$ ruby ../examples/ruby/reactor/broker.rb  --address=0.0.0.0:8888
+Listening on 0.0.0.0:8888
+````
+
+This example broker will receive messages, create queues as needed, and deliver messages to endpoints.
+
+### Hello World Using A Broker
+
+Our first example creates an endpoint that sends messages to a queue to which it is subscribed. So it both sends and receives its message in one pass.
+
+To start it, simply run:
+
+```
+$ ruby ../examples/ruby/reactor/helloworld.rb --address=0.0.0.0:8888 --queue=examples
+Hello world!
+```
+
+As you can see, the classic message was output by the example. Now let's take a look at what's going on under the covers.
+
+#### Events When Talking To A Broker
+
+The following events occur while **helloworld.rb** runs:
+
+ * **on_start** - Fired when the application is started.
+ * **on_sendable** - Fired when a message can be sent.
+ * **on_message** - Fired when a message is received.
+
+### Hello World Without A Broker required
+
+The next example we'll look at will send the classic "Hello world" message to itself directly. This example shows some very fundamental elements of the reactor APIs that you should understand.
+
+To launch the example:
+
+```
+ $ ruby helloworld_direct.rb --address=0.0.0.0:8888/examples
+ Hello world!
+```
+
+Not very different from the example that uses the broker, which is what we'd expect from the outside. But let's take a look inside of the example and see how it's different at that level
+
+The direct version takes on the responsibility for listening to incoming connections as well as making an outgoing connection. So we see the following additional events occurring:
+
+ * **on_accepted** - Fired when a message is received.
+ * **on_connection_closed** - Fired when an endpoint closes its connection.
+
+## More Complex Reactor Examples
+
+Now that we've covered the basics with the archetypical hello world app, let's look at some more interesting examples.
+
+There are four example applications that demonstrate how to send and receive messages both directly and through an intermediary, such as a broker:
+
+ * **simple_send.rb** - sends messages to a receiver at a specific address and receives responses via an intermediary,
+ * **simple_recv.rb** - receives messages from via an intermediary,
+ * **direct_send.rb** - sends messages directly to a receiver and listens for responses itself, and
+ * **direct_recv.rb** - receives messages directly.
+
+ Simple send and direct send may, at first, seem to be so similar that you wonder why they're not just the same applciation. And I know for me I was wonder as I wrote the list above why there were two examples. The reason is that **simple_send.rb** uses the intermediary transfer responses to the messages it sends, while **direct_send.rb** uses an *Acceptor* to listen for an process responses.
+
+ You can use the examples in the follow ways:
+
+ ```
+ simple_send.rb -> broker <- simple_recv.rb
+ simple_send.rb -> direct_recv.rb
+ direct_send.rb -> simple_recv.rb
+ ```
+
+In this set of examples we see the following event occurring, in addition to what we've seen before:
+
+ * **on_disconnected** - Fired when the transport is closed.
+
+## Now About That Broker example
+
+The **broker.rb** example application is a nice demonstration of doing something more interesting in Ruby with Proton.
+
+The way the broker works is to listen to incoming connections, examine the components of the address for that connection, attach that connection to an exchange managing that address and then it sends any messages destined for that address to them.
+
+The components of the broker example include:
+ * **Broker** - A class that extends the MessagingHandler class. It accepts incoming connections, manages subscribing them to exchanges, and transfers messages between them.
+ * **Exchange** - A class that represents a message queue, tracking what endpoints are subscribed to it.
+
+The Broker manages a map connecting a queue address to the instance of Exchange that holds references to the endpoints of interest.
+
+The broker application demonstrates a new set of reactor events:
+
+ * **on_link_opening** - Fired when a remote link is opened but the local end is not yet open. From this event the broker grabs the address and subscribes the link to an exchange for that address.
+ * **on_link_closing** - Fired when a remote link is closed but the local end is still open. From this event the broker grabs the address and unsubscribes the link from that exchange.
+ * **on_connection_closing** - Fired when a remote connection is closed but the local end is still open.
+ * **on_disconnected** - Fired when the protocol transport has closed. The broker removes all links for the disconnected connection, avoiding workign with endpoints that are now gone.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/broker.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/broker.rb b/examples/ruby/broker.rb
new file mode 100644
index 0000000..2c37a39
--- /dev/null
+++ b/examples/ruby/broker.rb
@@ -0,0 +1,198 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+require 'pathname'
+
+def debug(text)
+  print "[#{Time.now.strftime('%s')}] #{text}\n" if $options[:debug]
+end
+
+class Exchange
+
+  def initialize(dynamic = false)
+    @dynamic = dynamic
+    @queue = Queue.new
+    @consumers = []
+  end
+
+  def subscribe(consumer)
+    debug("subscribing #{consumer}")
+    @consumers << (consumer)
+    debug(" there are #{@consumers.size} consumers")
+  end
+
+  def unsubscribe(consumer)
+    debug("unsubscribing #{consumer}")
+    if @consumers.include?(consumer)
+      @consumers.delete(consumer)
+    else
+      debug(" consumer doesn't exist")
+    end
+    debug("  there are #{@consumers.size} consumers")
+    @consumers.empty? && (@dynamic || @queue.empty?)
+  end
+
+  def publish(message)
+    debug("queueing message: #{message.body}")
+    @queue << message
+    self.dispatch
+  end
+
+  def dispatch(consumer = nil)
+    debug("dispatching: consumer=#{consumer}")
+    if consumer
+      c = [consumer]
+    else
+      c = @consumers
+    end
+
+    while self.deliver_to(c) do
+    end
+  end
+
+  def deliver_to(consumers)
+    debug("delivering to #{consumers.size} consumer(s)")
+    result = false
+    consumers.each do |consumer|
+      debug(" current consumer=#{consumer} credit=#{consumer.credit}")
+      if consumer.credit > 0 && !@queue.empty?
+        consumer.send(@queue.pop(true))
+        result = true
+      end
+    end
+    return result
+  end
+
+end
+
+class Broker < Qpid::Proton::Handler::MessagingHandler
+
+  def initialize(url)
+    super()
+    @url = url
+    @queues = {}
+  end
+
+  def on_start(event)
+    debug("on_start event")
+    @acceptor = event.container.listen(@url)
+    print "Listening on #{@url}\n"
+  end
+
+  def queue(address)
+    debug("fetching queue for #{address}: (there are #{@queues.size} queues)")
+    unless @queues.has_key?(address)
+      debug(" creating new queue")
+      @queues[address] = Exchange.new
+    else
+      debug(" using existing queue")
+    end
+    result = @queues[address]
+    debug(" returning #{result}")
+    return result
+  end
+
+  def on_link_opening(event)
+    debug("processing on_link_opening")
+    debug("link is#{event.link.sender? ? '' : ' not'} a sender")
+    if event.link.sender?
+      if event.link.remote_source.dynamic?
+        address = SecureRandom.uuid
+        event.link.source.address = address
+        q = Exchange.new(true)
+        @queues[address] = q
+        q.subscribe(event.link)
+      elsif event.link.remote_source.address
+        event.link.source.address = event.link.remote_source.address
+        self.queue(event.link.source.address).subscribe(event.link)
+      end
+    elsif event.link.remote_target.address
+      event.link.target.address = event.link.remote_target.address
+    end
+  end
+
+  def unsubscribe(link)
+    debug("unsubscribing #{link.source.address}")
+    if @queues.has_key?(link.source.address)
+      if @queues[link.source.address].unsubscribe(link)
+        @queues.delete(link.source.address)
+      end
+    end
+  end
+
+  def on_link_closing(event)
+    self.unsubscribe(event.link) if event.link.sender?
+  end
+
+  def on_connection_closing(event)
+    self.remove_stale_consumers(event.connection)
+  end
+
+  def on_disconnected(event)
+    self.remove_stale_consumers(event.connection)
+  end
+
+  def remove_stale_consumers(connection)
+    l = connection.link_head(Qpid::Proton::Endpoint::REMOTE_ACTIVE)
+    while !l.nil?
+      self.unsubscribe(l) if l.sender?
+      l = l.next(Qpid::Proton::Endpoint::REMOTE_ACTIVE)
+    end
+  end
+
+  def on_sendable(event)
+    debug("on_sendable event")
+    q = self.queue(event.link.source.address)
+    debug(" dispatching #{event.message} to #{q}")
+    q.dispatch(event.link)
+  end
+
+  def on_message(event)
+    debug("on_message event")
+    q = self.queue(event.link.target.address)
+    debug(" dispatching #{event.message} to #{q}")
+    q.publish(event.message)
+  end
+
+end
+
+$options = {
+  :address => "localhost:5672",
+  :debug => false
+}
+
+OptionParser.new do |opts|
+  opts.banner = "Usage: #{Pathname.new(__FILE__).basename} [$options]"
+
+  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{$options[:address]}).") do |address|
+    $options[:address] = address
+  end
+
+  opts.on("-d", "--debug", "Enable debugging output (def. #{$options[:debug]})") do
+    $options[:debug] = true
+  end
+
+end.parse!
+
+begin
+  Qpid::Proton::Reactor::Container.new(Broker.new($options[:address])).run
+rescue Interrupt
+end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/client.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/client.rb b/examples/ruby/client.rb
new file mode 100644
index 0000000..8c38f38
--- /dev/null
+++ b/examples/ruby/client.rb
@@ -0,0 +1,82 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+class Client < Qpid::Proton::Handler::MessagingHandler
+
+  def initialize(url, requests)
+    super()
+    @url = url
+    @requests = requests
+  end
+
+  def on_start(event)
+    @sender = event.container.create_sender(@url)
+    @receiver = event.container.create_receiver(@sender.connection, :dynamic => true)
+  end
+
+  def next_request
+    if @receiver.remote_source.address
+      req = Qpid::Proton::Message.new
+      req.reply_to = @receiver.remote_source.address
+      req.body = @requests.first
+      puts "-> #{req.body}"
+      @sender.send(req)
+    end
+  end
+
+  def on_link_opened(event)
+    if event.receiver == @receiver
+      next_request
+    end
+  end
+
+  def on_message(event)
+    puts "<- #{event.message.body}"
+    @requests.delete_at(0)
+    if !@requests.empty?
+      next_request
+    else
+      event.connection.close
+    end
+  end
+
+  def on_transport_error(event)
+    raise "Connection error: #{event.transport.condition}"
+  end
+
+end
+
+REQUESTS = ["Twas brillig, and the slithy toves",
+            "Did gire and gymble in the wabe.",
+            "All mimsy were the borogroves,",
+            "And the mome raths outgrabe."]
+
+options = {
+  :address => "localhost:5672/examples",
+}
+
+OptionParser.new do |opts|
+  opts.banner = "Usage: client.rb [options]"
+  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") { |address| options[:address] = address }
+end.parse!
+
+Qpid::Proton::Reactor::Container.new(Client.new(options[:address], REQUESTS)).run

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/direct_recv.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/direct_recv.rb b/examples/ruby/direct_recv.rb
new file mode 100644
index 0000000..411efba
--- /dev/null
+++ b/examples/ruby/direct_recv.rb
@@ -0,0 +1,66 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+class DirectReceive < Qpid::Proton::Handler::MessagingHandler
+
+  def initialize(url, expected)
+    super()
+    @url = url
+    @expected = expected
+    @received = 0
+  end
+
+  def on_start(event)
+    @acceptor = event.container.listen(@url)
+  end
+
+  def on_message(event)
+    if @expected.zero? || (@received < @expected)
+      puts "Received: #{event.message.body}"
+      @received = @received + 1
+      if @received == @expected
+        event.connection.close
+        @acceptor.close
+      end
+    end
+  end
+end
+
+options = {
+  :address => "localhost:5672/examples",
+  :messages => 100,
+}
+
+OptionParser.new do |opts|
+  opts.banner = "Usage: simple_send.rb [options]"
+
+  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
+    options[:address] = address
+  end
+
+  opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
+    OptionParser::DecimalInteger) do |messages|
+    options[:messages] = messages
+  end
+end.parse!
+
+Qpid::Proton::Reactor::Container.new(DirectReceive.new(options[:address], options[:messages])).run

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/direct_send.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/direct_send.rb b/examples/ruby/direct_send.rb
new file mode 100644
index 0000000..ed679aa
--- /dev/null
+++ b/examples/ruby/direct_send.rb
@@ -0,0 +1,76 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+options = {
+  :address => "localhost:5672/examples",
+  :messages => 100,
+}
+
+class SimpleSend < Qpid::Proton::Handler::MessagingHandler
+
+  def initialize(url, expected)
+    super()
+    @url = url
+    @sent = 0
+    @confirmed = 0
+    @expected = expected
+  end
+
+  def on_start(event)
+    @acceptor = event.container.listen(@url)
+  end
+
+  def on_sendable(event)
+    while event.sender.credit > 0 && @sent < @expected
+      msg = Qpid::Proton::Message.new("sequence #{@sent}", { :id => @sent } )
+      event.sender.send(msg)
+      @sent = @sent + 1
+    end
+  end
+
+  def on_accepted(event)
+    @confirmed = @confirmed + 1
+    if @confirmed == @expected
+      puts "All #{@expected} messages confirmed!"
+      event.connection.close
+    end
+  end
+end
+
+OptionParser.new do |opts|
+  opts.banner = "Usage: simple_send.rb [options]"
+
+  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
+    options[:address] = address
+  end
+
+  opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
+    OptionParser::DecimalInteger) do |messages|
+    options[:messages] = messages
+  end
+end.parse!
+
+begin
+  Qpid::Proton::Reactor::Container.new(SimpleSend.new(options[:address], options[:messages])).run
+rescue Interrupt => error
+  puts "ERROR: #{error}"
+end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/engine_recv.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/engine_recv.rb b/examples/ruby/engine_recv.rb
deleted file mode 100644
index 1529964..0000000
--- a/examples/ruby/engine_recv.rb
+++ /dev/null
@@ -1,158 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-require "qpid_examples"
-require "optparse"
-
-DEFAULT_PORT = 5672
-
-options = {
-  :port => DEFAULT_PORT,
-  :debug => false,
-  :verbose => false,
-}
-
-OptionParser.new do |opts|
-  opts.banner = "Usage: engine_recv.rb [options]"
-
-  opts.on("-p [port]", "--port [port]",
-          "The port to use  (def. #{DEFAULT_PORT})") do |port|
-    options[:port] = port
-  end
-
-  opts.on("-v", "--verbose",
-          "Enable verbose output") do
-    options[:verbose] = true
-  end
-
-  opts.on("-d",
-          "--debug", "Enable debugging") do
-    options[:debug] = true
-  end
-
-  opts.parse!
-end
-
-server = TCPServer.new('localhost', options[:port])
-
-last_time = Time.now
-
-message_count = 0
-driver = Driver.new
-
-collector = Qpid::Proton::Event::Collector.new
-
-loop do
-  begin
-    client = server.accept_nonblock
-  rescue Errno::EAGAIN, Errno::ECONNABORTED, Errno::EINTR, Errno::EWOULDBLOCK => error
-
-  end
-
-  unless client.nil?
-    puts "Connection from #{client.peeraddr.last}"
-    connection = Qpid::Proton::Connection.new
-    connection.collect(collector)
-    transport = Qpid::Proton::Transport.new(Qpid::Proton::Transport::SERVER)
-    transport.bind(connection)
-    selectable = Selectable.new(transport, client)
-    driver.add(selectable)
-  end
-
-  # let the driver process data
-  driver.process
-
-  event = collector.peek
-
-  while !event.nil?
-    puts "EVENT: #{event}" if options[:debug]
-
-    case event.type
-    when Qpid::Proton::Event::CONNECTION_INIT
-      conn = event.connection
-      if conn.state & Qpid::Proton::Endpoint::REMOTE_UNINIT
-        conn.transport.sasl.done(Qpid::Proton::SASL::OK)
-      end
-
-    when Qpid::Proton::Event::CONNECTION_BOUND
-      conn = event.connection
-      if conn.state & Qpid::Proton::Endpoint::LOCAL_UNINIT
-        conn.open
-      end
-
-    when Qpid::Proton::Event::CONNECTION_REMOTE_CLOSE
-      conn = event.context
-      if !(conn.state & Qpid::Proton::Endpoint::LOCAL_CLOSED)
-        conn.close
-      end
-
-    when Qpid::Proton::Event::SESSION_REMOTE_OPEN
-      session = event.session
-      if session.state & Qpid::Proton::Endpoint::LOCAL_UNINIT
-        session.incoming_capacity = 1000000
-        session.open
-      end
-
-    when Qpid::Proton::Event::SESSION_REMOTE_CLOSE
-      session = event.session
-      if !(session.state & Qpid::Proton::Endpoint::LOCAL_CLOSED)
-        session.close
-      end
-
-    when Qpid::Proton::Event::LINK_REMOTE_OPEN
-      link = event.link
-      if link.state & Qpid::Proton::Endpoint::LOCAL_UNINIT
-        link.open
-        link.flow 400
-      end
-
-    when Qpid::Proton::Event::LINK_REMOTE_CLOSE
-      link = event.context
-      if !(link.state & Qpid::Proton::Endpoint::LOCAL_CLOSED)
-        link.close
-      end
-
-    when Qpid::Proton::Event::DELIVERY
-      link = event.link
-      delivery = event.delivery
-      if delivery.readable? && !delivery.partial?
-        # decode the message and display it
-        msg = Qpid::Proton::Util::Engine.receive_message(delivery)
-        message_count += 1
-        puts "Received:"
-        puts " Count=#{message_count}" if options[:verbose]
-        puts " From=#{msg.id}" if msg.id
-        puts " Reply to=#{msg.reply_to}" if msg.reply_to
-        puts " Subject=#{msg.subject}" if msg.subject
-        puts " Body=#{msg.body}" if msg.body
-        puts ""
-        delivery.settle
-        credit = link.credit
-        link.flow(200) if credit <= 200
-      end
-
-    when Qpid::Proton::Event::TRANSPORT
-      driver.process
-
-    end
-
-    collector.pop
-    event = collector.peek
-  end
-end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/engine_send.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/engine_send.rb b/examples/ruby/engine_send.rb
deleted file mode 100644
index 189c7fd..0000000
--- a/examples/ruby/engine_send.rb
+++ /dev/null
@@ -1,143 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-require 'qpid_examples'
-require "optparse"
-
-DEFAULT_ADDRESS = "0.0.0.0:5672"
-
-options = {
-  :address => DEFAULT_ADDRESS,
-  :debug => false,
-  :verbose => false,
-  :count => 1,
-  :content => "This message was sent #{Time.new}"
-}
-
-OptionParser.new do |opts|
-  opts.banner = "Usage: engine_recv.rb [options]"
-
-  opts.on("-a [address]", "--address [address]",
-          "The target address (def. #{DEFAULT_ADDRESS})") do |address|
-    options[:address] = address
-  end
-
-  opts.on("-C [content]", "--content [content]",
-          "The message content") do |content|
-    options[:content] = content
-  end
-
-  opts.on("-c [count]", "--count [count]",
-          "The number of messages to send (def. 1)") do |count|
-    options[:count] = count.to_i
-  end
-
-  opts.on("-v", "--verbose",
-          "Enable verbose output") do
-    options[:verbose] = true
-  end
-
-  opts.on("-d",
-          "--debug", "Enable debugging") do
-    options[:debug] = true
-  end
-
-  opts.parse!
-end
-
-
-driver = Driver.new
-
-conn = Qpid::Proton::Connection.new
-collector = Qpid::Proton::Event::Collector.new
-conn.collect(collector)
-
-session = conn.session
-conn.open
-session.open
-
-sender = session.sender("tvc_15_1")
-sender.target.address = "queue"
-sender.open
-
-transport = Qpid::Proton::Transport.new
-transport.bind(conn)
-
-address, port = options[:address].split(":")
-
-socket = TCPSocket.new(address, port)
-selectable = Selectable.new(transport, socket)
-sent_count = 0
-
-sent_count = 0
-
-driver.add(selectable)
-
-loop do
-  # let the driver process
-  driver.process
-
-  event = collector.peek
-
-  unless event.nil?
-
-    print "EVENT: #{event}\n" if options[:debug]
-
-    case event.type
-
-    when Qpid::Proton::Event::LINK_FLOW
-      sender = event.sender
-      credit = sender.credit
-
-      message = Qpid::Proton::Message.new
-
-      if credit > 0 && sent_count < options[:count]
-        sent_count = sent_count.next
-        message.clear
-        message.address = options[:address]
-        message.subject = "Message #{sent_count}..."
-        message.body = options[:content]
-
-        delivery = sender.delivery("#{sent_count}")
-        sender.send(message.encode)
-        delivery.settle
-        sender.advance
-        credit = sender.credit
-      else
-        sender.close
-      end
-
-    when Qpid::Proton::Event::LINK_LOCAL_CLOSE
-      link = event.link
-      link.close
-      link.session.close
-
-    when Qpid::Proton::Event::SESSION_LOCAL_CLOSE
-      session = event.session
-      session.connection.close
-
-    when Qpid::Proton::Event::CONNECTION_LOCAL_CLOSE
-      break
-
-    end
-
-    collector.pop
-    event = collector.peek
-  end
-end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/example_test.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/example_test.rb b/examples/ruby/example_test.rb
index 86890ce..12ab784 100755
--- a/examples/ruby/example_test.rb
+++ b/examples/ruby/example_test.rb
@@ -25,26 +25,53 @@ require 'socket'
 class ExampleTest < MiniTest::Test
 
   def run_script(script, port)
-    assert File.exist? script
     cmd = [RbConfig.ruby, script]
     cmd += ["-a", ":#{port}/examples"] if port
     return IO.popen(cmd)
   end
 
-
   def assert_output(script, want, port=nil)
     out = run_script(script, port)
     assert_equal want, out.read.strip
   end
 
   def test_helloworld
-    assert_output("reactor/helloworld.rb", "Hello world!", $port)
+    assert_output("helloworld.rb", "Hello world!", $port)
   end
 
   def test_send_recv
-    assert_output("reactor/simple_send.rb", "All 100 messages confirmed!", $port)
+    assert_output("simple_send.rb", "All 100 messages confirmed!", $port)
     want = (0..99).reduce("") { |x,y| x << "Received: sequence #{y}\n" }
-    assert_output("reactor/simple_recv.rb", want.strip, $port)
+    assert_output("simple_recv.rb", want.strip, $port)
+  end
+
+  def test_direct_recv
+    TestPort.new do |tp|
+      p = run_script("direct_recv.rb", tp.port)
+      wait_port tp.port
+      assert_output("simple_send.rb", "All 100 messages confirmed!", tp.port)
+      want = (0..99).reduce("") { |x,y| x << "Received: sequence #{y}\n" }
+      assert_equal(want.strip, p.read.strip)
+    end
+  end
+
+  def test_direct_send
+    TestPort.new do |tp|
+      p = run_script("direct_send.rb", tp.port)
+      wait_port tp.port
+      want = (0..99).reduce("") { |x,y| x << "Received: sequence #{y}\n" }
+      assert_output("simple_recv.rb", want.strip, $port)
+      assert_equal("All 100 messages confirmed!", p.read.strip)
+    end
+  end
+
+  def test_direct_send
+    TestPort.start_wait do |port|
+      p = run_script("direct_recv.rb", port)
+      assert_output("simple_send.rb", "All 100 messages confirmed!", port)
+      want = (0..99).reduce("") { |x,y| x << "Received: sequence #{y}\n" }
+      assert_equal(want.strip, p.read.strip)
+    end
   end
 
   def test_client_server
@@ -58,8 +85,8 @@ class ExampleTest < MiniTest::Test
 -> And the mome raths outgrabe.
 <- AND THE MOME RATHS OUTGRABE.
 EOS
-    srv = run_script("reactor/server.rb", $port)
-    assert_output("reactor/client.rb", want.strip, $port)
+    srv = run_script("server.rb", $port)
+    assert_output("client.rb", want.strip, $port)
 
   ensure
     Process.kill :TERM, srv.pid if srv

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/helloworld.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/helloworld.rb b/examples/ruby/helloworld.rb
new file mode 100644
index 0000000..9b02e8a
--- /dev/null
+++ b/examples/ruby/helloworld.rb
@@ -0,0 +1,73 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+class HelloWorld < Qpid::Proton::Handler::MessagingHandler
+
+  def initialize(server, address)
+    super()
+    @server = server
+    @address = address
+  end
+
+  def on_start(event)
+    conn = event.container.connect(:address => @server)
+    event.container.create_sender(conn, :target => @address)
+    event.container.create_receiver(conn, :source => @address)
+  end
+
+  def on_sendable(event)
+    msg = Qpid::Proton::Message.new
+    msg.body = "Hello world!"
+    event.sender.send(msg)
+    event.sender.close
+  end
+
+  def on_message(event)
+    puts event.message.body
+    event.connection.close
+  end
+
+  def on_transport_error(event)
+    raise "Connection error: #{event.transport.condition}"
+  end
+end
+
+options = {
+  :address => "localhost:5672",
+  :queue => "examples"
+}
+
+OptionParser.new do |opts|
+  opts.banner = "Usage: helloworld_direct.rb [options]"
+
+  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
+    options[:address] = address
+  end
+
+  opts.on("-q", "--queue=QUEUE", "Send messages to QUEUE (def. #{options[:queue]})") do |queue|
+    options[:queue] = queue
+  end
+
+end.parse!
+
+hw = HelloWorld.new(options[:address], "examples")
+Qpid::Proton::Reactor::Container.new(hw).run

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/helloworld_direct.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/helloworld_direct.rb b/examples/ruby/helloworld_direct.rb
new file mode 100644
index 0000000..e98cc1f
--- /dev/null
+++ b/examples/ruby/helloworld_direct.rb
@@ -0,0 +1,74 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+options = {
+  :address => "localhost:5672/examples",
+}
+
+class HelloWorldDirect < Qpid::Proton::Handler::MessagingHandler
+
+  include Qpid::Proton::Util::Wrapper
+
+  def initialize(url)
+    super()
+    @url = url
+  end
+
+  def on_start(event)
+    @acceptor = event.container.listen(@url)
+    event.container.create_sender(@url)
+  end
+
+  def on_sendable(event)
+    msg = Qpid::Proton::Message.new
+    msg.body = "Hello world!"
+    event.sender.send(msg)
+    event.sender.close
+  end
+
+  def on_message(event)
+    puts "#{event.message.body}"
+  end
+
+  def on_accepted(event)
+    event.connection.close
+  end
+
+  def on_connection_closed(event)
+    @acceptor.close
+  end
+
+end
+
+OptionParser.new do |opts|
+  opts.banner = "Usage: helloworld_direct.rb [options]"
+
+  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
+    options[:address] = address
+  end
+
+end.parse!
+
+begin
+  Qpid::Proton::Reactor::Container.new(HelloWorldDirect.new(options[:address])).run
+rescue Interrupt => error
+end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/lib/debugging.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/lib/debugging.rb b/examples/ruby/lib/debugging.rb
deleted file mode 100644
index 5065d51..0000000
--- a/examples/ruby/lib/debugging.rb
+++ /dev/null
@@ -1,26 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-module Debugging
-
-  def debug(text)
-    print "[#{Time.now.strftime('%s')}] #{text}\n"
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/lib/driver.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/lib/driver.rb b/examples/ruby/lib/driver.rb
deleted file mode 100644
index 4e223d0..0000000
--- a/examples/ruby/lib/driver.rb
+++ /dev/null
@@ -1,69 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-class Driver
-
-  def initialize
-    @selectables = {}
-  end
-
-  def add(selectable)
-    @selectables[selectable.fileno] = selectable
-  end
-
-  def process
-    reading = []
-    writing = []
-
-    @selectables.each_value do |sel|
-      if sel.closed? || sel.fileno.nil?
-        @selectables.delete(sel.fileno)
-      else
-        begin
-          reading << sel.to_io if sel.reading?
-          writing << sel.to_io if sel.writing?
-        rescue Exception => error
-          puts "Error: #{error}"
-          puts error.backtrace.join("\n");
-          # @selectables.delete(sel.fileno)
-        end
-      end
-    end
-
-    read_from, write_to = IO.select(reading, writing, [], 0)
-
-    unless read_from.nil?
-      read_from.each do |r|
-        sel = @selectables[r.fileno]
-        sel.readable unless sel.nil? || sel.closed?
-      end
-    end
-
-    begin
-      unless write_to.nil?
-        write_to.each do |w|
-          sel = @selectables[w.fileno]
-          sel.writable unless sel.nil? || sel.closed?
-        end
-      end
-
-    end
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/lib/qpid_examples.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/lib/qpid_examples.rb b/examples/ruby/lib/qpid_examples.rb
deleted file mode 100644
index 8503fbe..0000000
--- a/examples/ruby/lib/qpid_examples.rb
+++ /dev/null
@@ -1,28 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-require "qpid_proton"
-
-require "selectable"
-require "driver"
-require "socket"
-require "monitor"
-
-include Socket::Constants
-

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/lib/selectable.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/lib/selectable.rb b/examples/ruby/lib/selectable.rb
deleted file mode 100644
index 779ea24..0000000
--- a/examples/ruby/lib/selectable.rb
+++ /dev/null
@@ -1,120 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-class Selectable
-
-  attr_reader :transport
-
-  def initialize(transport, socket)
-    @transport = transport
-    @socket = socket
-    @socket.autoclose = true
-    @write_done = false
-    @read_done = false
-  end
-
-  def closed?
-    return true if @socket.closed?
-    return false if !@read_done && !@write_done
-    @socket.close
-    true
-  end
-
-  def fileno
-    @socket.fileno unless @socket.closed?
-  end
-
-  def to_io
-    @socket
-  end
-
-  def reading?
-    return false if @read_done
-    c = @transport.capacity
-    if c > 0
-      return true
-    elsif c < 0
-      @read_done = true
-      return false
-    else
-      return false
-    end
-  end
-
-  def writing?
-    return false if @write_done
-    begin
-      p = @transport.pending
-      if p > 0
-        return true
-      elsif p < 0
-        @write_done = true
-        return false
-      else
-        return false
-      end
-    rescue Qpid::Proton::TransportError => error
-      @write_done = true
-      return false
-    end
-  end
-
-  def readable
-    c = @transport.capacity
-    if c > 0
-      begin
-        data = @socket.recv(c)
-        if data
-          @transport.push(data)
-        else
-          @transport.close_tail
-        end
-      rescue Exception => error
-        puts "read error; #{error}"
-        @transport.close_tail
-        @read_done = true
-      end
-    elsif c < 0
-      @read_done = true
-    end
-  end
-
-  def writable
-    begin
-      p = @transport.pending
-      if p > 0
-        data = @transport.peek(p)
-        n = @socket.send(data, 0)
-        @transport.pop(n)
-      elsif p < 0
-        @write_done = true
-      end
-    rescue Exception => error
-      puts "write error: #{error}"
-      puts error.backtrace.join("\n")
-      @transport.close_head
-      @write_done = true
-    end
-  end
-
-  def tick(now)
-    @transport.tick(now)
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/lib/send_and_receive.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/lib/send_and_receive.rb b/examples/ruby/lib/send_and_receive.rb
deleted file mode 100644
index 9fd7417..0000000
--- a/examples/ruby/lib/send_and_receive.rb
+++ /dev/null
@@ -1,90 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-class ExampleSend < Qpid::Proton::Handler::MessagingHandler
-
-  attr_reader :url
-
-  def initialize(url, expected)
-    super()
-    @url = url
-    @sent = 0
-    @confirmed = 0
-    @expected = expected
-  end
-
-  def on_sendable(event)
-    while event.sender.credit > 0 && @sent < @expected
-      msg = Qpid::Proton::Message.new
-      msg.body = "sequence #{@sent}"
-      msg.id = @sent
-      event.sender.send(msg)
-      @sent = @sent + 1
-    end
-  end
-
-  def on_accepted(event)
-    @confirmed = @confirmed + 1
-    if self.finished?
-      puts "#{@expected > 1 ? 'All ' : ''}#{@expected} message#{@expected > 1 ? 's' : ''} confirmed!"
-      event.connection.close
-    end
-  end
-
-  def on_disconnected(event)
-    @sent = @confirmed
-  end
-
-  def finished?
-    @confirmed == @expected
-  end
-
-end
-
-class ExampleReceive < Qpid::Proton::Handler::MessagingHandler
-
-  attr_reader :url
-
-  def initialize(url, expected)
-    super()
-    @url = url
-    @expected = expected
-    @received = 0
-  end
-
-  def on_message(event)
-    if event.message.id.nil? || event.message.id < @received
-      puts "Missing or old message id: id=#{event.message.id}"
-      return
-    end
-    if @expected.zero? || (@received < @expected)
-      puts "Received: #{event.message.body}"
-      @received = @received + 1
-      if finished?
-        event.receiver.close
-        event.connection.close
-      end
-    end
-  end
-
-  def finished?
-    @received == @expected
-  end
-
-end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/reactor/README.md
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/README.md b/examples/ruby/reactor/README.md
deleted file mode 100644
index 38cc6ba..0000000
--- a/examples/ruby/reactor/README.md
+++ /dev/null
@@ -1,103 +0,0 @@
-## What Is The Reactor?
-
-A little outside of the scope of this document, but the reactor is an event source for letting an application know about events in the Proton messaging system. With this set of APIs an application can be register handlers that are notified when a connection is created, a message received, or a session closes.
-
-### Handlers
-
-An application creates **handlers**, objects which provide methods through which the reactor notifies the application's components of events and allows them each to handle the ones in which they are interested (see the Chain Of Responsibility design pattern for more on this idea). There are some pre-defined handlers for responding to incoming message events, outgoing message events, data flow and managing the AMQP endpoints. Look in the **Qpid::Proton::Handlers** package for more details on these classes.
-
-## Simple Reactor Examples
-
-### The Broker
-
-The reactor examples come with a sample broker which can be used by other examples and which also works as an example itself. For now we'll just start up the broker example and tell it to listen on port 8888:
-
-````
-$ ruby ../examples/ruby/reactor/broker.rb  --address=0.0.0.0:8888
-Listening on 0.0.0.0:8888
-````
-
-This example broker will receive messages, create queues as needed, and deliver messages to endpoints.
-
-### Hello World Using A Broker
-
-Our first example creates an endpoint that sends messages to a queue to which it is subscribed. So it both sends and receives its message in one pass.
-
-To start it, simply run:
-
-```
-$ ruby ../examples/ruby/reactor/helloworld.rb --address=0.0.0.0:8888 --queue=examples
-Hello world!
-```
-
-As you can see, the classic message was output by the example. Now let's take a look at what's going on under the covers.
-
-#### Events When Talking To A Broker
-
-The following events occur while **helloworld.rb** runs:
-
- * **on_start** - Fired when the application is started.
- * **on_sendable** - Fired when a message can be sent.
- * **on_message** - Fired when a message is received.
-
-### Hello World Without A Broker required
-
-The next example we'll look at will send the classic "Hello world" message to itself directly. This example shows some very fundamental elements of the reactor APIs that you should understand.
-
-To launch the example:
-
-```
- $ ruby helloworld_direct.rb --address=0.0.0.0:8888/examples
- Hello world!
-```
-
-Not very different from the example that uses the broker, which is what we'd expect from the outside. But let's take a look inside of the example and see how it's different at that level
-
-The direct version takes on the responsibility for listening to incoming connections as well as making an outgoing connection. So we see the following additional events occurring:
-
- * **on_accepted** - Fired when a message is received.
- * **on_connection_closed** - Fired when an endpoint closes its connection.
-
-## More Complex Reactor Examples
-
-Now that we've covered the basics with the archetypical hello world app, let's look at some more interesting examples.
-
-There are four example applications that demonstrate how to send and receive messages both directly and through an intermediary, such as a broker:
-
- * **simple_send.rb** - sends messages to a receiver at a specific address and receives responses via an intermediary,
- * **simple_recv.rb** - receives messages from via an intermediary,
- * **direct_send.rb** - sends messages directly to a receiver and listens for responses itself, and
- * **direct_recv.rb** - receives messages directly.
-
- Simple send and direct send may, at first, seem to be so similar that you wonder why they're not just the same applciation. And I know for me I was wonder as I wrote the list above why there were two examples. The reason is that **simple_send.rb** uses the intermediary transfer responses to the messages it sends, while **direct_send.rb** uses an *Acceptor* to listen for an process responses.
-
- You can use the examples in the follow ways:
-
- ```
- simple_send.rb -> broker <- simple_recv.rb
- simple_send.rb -> direct_recv.rb
- direct_send.rb -> simple_recv.rb
- ```
-
-In this set of examples we see the following event occurring, in addition to what we've seen before:
-
- * **on_disconnected** - Fired when the transport is closed.
-
-## Now About That Broker example
-
-The **broker.rb** example application is a nice demonstration of doing something more interesting in Ruby with Proton.
-
-The way the broker works is to listen to incoming connections, examine the components of the address for that connection, attach that connection to an exchange managing that address and then it sends any messages destined for that address to them.
-
-The components of the broker example include:
- * **Broker** - A class that extends the MessagingHandler class. It accepts incoming connections, manages subscribing them to exchanges, and transfers messages between them.
- * **Exchange** - A class that represents a message queue, tracking what endpoints are subscribed to it.
-
-The Broker manages a map connecting a queue address to the instance of Exchange that holds references to the endpoints of interest.
-
-The broker application demonstrates a new set of reactor events:
-
- * **on_link_opening** - Fired when a remote link is opened but the local end is not yet open. From this event the broker grabs the address and subscribes the link to an exchange for that address.
- * **on_link_closing** - Fired when a remote link is closed but the local end is still open. From this event the broker grabs the address and unsubscribes the link from that exchange.
- * **on_connection_closing** - Fired when a remote connection is closed but the local end is still open.
- * **on_disconnected** - Fired when the protocol transport has closed. The broker removes all links for the disconnected connection, avoiding workign with endpoints that are now gone.

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/reactor/broker.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/broker.rb b/examples/ruby/reactor/broker.rb
deleted file mode 100644
index 7882d9a..0000000
--- a/examples/ruby/reactor/broker.rb
+++ /dev/null
@@ -1,200 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-require 'qpid_proton'
-require 'optparse'
-require 'pathname'
-
-require_relative '../lib/debugging'
-
-class Exchange
-
-  include Debugging
-
-  def initialize(dynamic = false)
-    @dynamic = dynamic
-    @queue = Queue.new
-    @consumers = []
-  end
-
-  def subscribe(consumer)
-    debug("subscribing #{consumer}") if $options[:debug]
-    @consumers << (consumer)
-    debug(" there are #{@consumers.size} consumers") if $options[:debug]
-  end
-
-  def unsubscribe(consumer)
-    debug("unsubscribing #{consumer}") if $options[:debug]
-    if @consumers.include?(consumer)
-      @consumers.delete(consumer)
-    else
-      debug(" consumer doesn't exist") if $options[:debug]
-    end
-    debug("  there are #{@consumers.size} consumers") if $options[:debug]
-    @consumers.empty? && (@dynamic || @queue.empty?)
-  end
-
-  def publish(message)
-    debug("queueing message: #{message.body}") if $options[:debug]
-    @queue << message
-    self.dispatch
-  end
-
-  def dispatch(consumer = nil)
-    debug("dispatching: consumer=#{consumer}") if $options[:debug]
-    if consumer
-      c = [consumer]
-    else
-      c = @consumers
-    end
-
-    while self.deliver_to(c) do
-    end
-  end
-
-  def deliver_to(consumers)
-    debug("delivering to #{consumers.size} consumer(s)") if $options[:debug]
-    result = false
-    consumers.each do |consumer|
-      debug(" current consumer=#{consumer} credit=#{consumer.credit}") if $options[:debug]
-      if consumer.credit > 0 && !@queue.empty?
-        consumer.send(@queue.pop(true))
-        result = true
-      end
-    end
-    return result
-  end
-
-end
-
-class Broker < Qpid::Proton::Handler::MessagingHandler
-
-  include Debugging
-
-  def initialize(url)
-    super()
-    @url = url
-    @queues = {}
-  end
-
-  def on_start(event)
-    debug("on_start event") if $options[:debug]
-    @acceptor = event.container.listen(@url)
-    print "Listening on #{@url}\n"
-  end
-
-  def queue(address)
-    debug("fetching queue for #{address}: (there are #{@queues.size} queues)") if $options[:debug]
-    unless @queues.has_key?(address)
-      debug(" creating new queue") if $options[:debug]
-      @queues[address] = Exchange.new
-    else
-      debug(" using existing queue") if $options[:debug]
-    end
-    result = @queues[address]
-    debug(" returning #{result}") if $options[:debug]
-    return result
-  end
-
-  def on_link_opening(event)
-    debug("processing on_link_opening") if $options[:debug]
-    debug("link is#{event.link.sender? ? '' : ' not'} a sender") if $options[:debug]
-    if event.link.sender?
-      if event.link.remote_source.dynamic?
-        address = SecureRandom.uuid
-        event.link.source.address = address
-        q = Exchange.new(true)
-        @queues[address] = q
-        q.subscribe(event.link)
-      elsif event.link.remote_source.address
-        event.link.source.address = event.link.remote_source.address
-        self.queue(event.link.source.address).subscribe(event.link)
-      end
-    elsif event.link.remote_target.address
-      event.link.target.address = event.link.remote_target.address
-    end
-  end
-
-  def unsubscribe(link)
-    debug("unsubscribing #{link.address}") if $options[:debug]
-    if @queues.has_key?(link.source.address)
-      if @queues[link.source.address].unsubscribe(link)
-        @queues.delete(link.source.address)
-      end
-    end
-  end
-
-  def on_link_closing(event)
-    self.unsubscribe(event.link) if event.link.sender?
-  end
-
-  def on_connection_closing(event)
-    self.remove_stale_consumers(event.connection)
-  end
-
-  def on_disconnected(event)
-    self.remove_stale_consumers(event.connection)
-  end
-
-  def remove_stale_consumers(connection)
-    l = connection.link_head(Qpid::Proton::Endpoint::REMOTE_ACTIVE)
-    while !l.nil?
-      self.unsubscribe(l) if l.sender?
-      l = l.next(Qpid::Proton::Endpoint::REMOTE_ACTIVE)
-    end
-  end
-
-  def on_sendable(event)
-    debug("on_sendable event") if $options[:debug]
-    q = self.queue(event.link.source.address)
-    debug(" dispatching #{event.message} to #{q}") if $options[:debug]
-    q.dispatch(event.link)
-  end
-
-  def on_message(event)
-    debug("on_message event") if $options[:debug]
-    q = self.queue(event.link.target.address)
-    debug(" dispatching #{event.message} to #{q}") if $options[:debug]
-    q.publish(event.message)
-  end
-
-end
-
-$options = {
-  :address => "localhost:5672",
-  :debug => false
-}
-
-OptionParser.new do |opts|
-  opts.banner = "Usage: #{Pathname.new(__FILE__).basename} [$options]"
-
-  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{$options[:address]}).") do |address|
-    $options[:address] = address
-  end
-
-  opts.on("-d", "--debug", "Enable debugging output (def. #{$options[:debug]})") do
-    $options[:debug] = true
-  end
-
-end.parse!
-
-begin
-  Qpid::Proton::Reactor::Container.new(Broker.new($options[:address])).run
-rescue Interrupt
-end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/reactor/client.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/client.rb b/examples/ruby/reactor/client.rb
deleted file mode 100644
index 8c38f38..0000000
--- a/examples/ruby/reactor/client.rb
+++ /dev/null
@@ -1,82 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-require 'qpid_proton'
-require 'optparse'
-
-class Client < Qpid::Proton::Handler::MessagingHandler
-
-  def initialize(url, requests)
-    super()
-    @url = url
-    @requests = requests
-  end
-
-  def on_start(event)
-    @sender = event.container.create_sender(@url)
-    @receiver = event.container.create_receiver(@sender.connection, :dynamic => true)
-  end
-
-  def next_request
-    if @receiver.remote_source.address
-      req = Qpid::Proton::Message.new
-      req.reply_to = @receiver.remote_source.address
-      req.body = @requests.first
-      puts "-> #{req.body}"
-      @sender.send(req)
-    end
-  end
-
-  def on_link_opened(event)
-    if event.receiver == @receiver
-      next_request
-    end
-  end
-
-  def on_message(event)
-    puts "<- #{event.message.body}"
-    @requests.delete_at(0)
-    if !@requests.empty?
-      next_request
-    else
-      event.connection.close
-    end
-  end
-
-  def on_transport_error(event)
-    raise "Connection error: #{event.transport.condition}"
-  end
-
-end
-
-REQUESTS = ["Twas brillig, and the slithy toves",
-            "Did gire and gymble in the wabe.",
-            "All mimsy were the borogroves,",
-            "And the mome raths outgrabe."]
-
-options = {
-  :address => "localhost:5672/examples",
-}
-
-OptionParser.new do |opts|
-  opts.banner = "Usage: client.rb [options]"
-  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") { |address| options[:address] = address }
-end.parse!
-
-Qpid::Proton::Reactor::Container.new(Client.new(options[:address], REQUESTS)).run

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/reactor/direct_recv.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/direct_recv.rb b/examples/ruby/reactor/direct_recv.rb
deleted file mode 100644
index 2e19b04..0000000
--- a/examples/ruby/reactor/direct_recv.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-require 'qpid_proton'
-require 'optparse'
-
-require_relative '../lib/send_and_receive'
-
-class DirectReceive < ExampleReceive
-
-  def initialize(url, expected)
-    super
-  end
-
-  def on_start(event)
-    @acceptor = event.container.listen(self.url)
-  end
-
-  def on_message(event)
-    super(event)
-    @acceptor.close if self.finished?
-  end
-
-end
-
-options = {
-  :address => "localhost:5672/examples",
-  :messages => 100,
-}
-
-OptionParser.new do |opts|
-  opts.banner = "Usage: simple_send.rb [options]"
-
-  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
-    options[:address] = address
-  end
-
-  opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
-    OptionParser::DecimalInteger) do |messages|
-    options[:messages] = messages
-  end
-end.parse!
-
-Qpid::Proton::Reactor::Container.new(DirectReceive.new(options[:address], options[:messages])).run

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/reactor/direct_send.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/direct_send.rb b/examples/ruby/reactor/direct_send.rb
deleted file mode 100644
index 22ce7de..0000000
--- a/examples/ruby/reactor/direct_send.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-require 'qpid_proton'
-require 'optparse'
-
-require_relative '../lib/send_and_receive'
-
-options = {
-  :address => "localhost:5672/examples",
-  :messages => 100,
-}
-
-class SimpleSend < ExampleSend
-
-  def initialize(url, messages)
-    super(url, messages)
-  end
-
-  def on_start(event)
-    @acceptor = event.container.listen(url)
-  end
-
-end
-
-OptionParser.new do |opts|
-  opts.banner = "Usage: simple_send.rb [options]"
-
-  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
-    options[:address] = address
-  end
-
-  opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
-    OptionParser::DecimalInteger) do |messages|
-    options[:messages] = messages
-  end
-end.parse!
-
-begin
-  Qpid::Proton::Reactor::Container.new(SimpleSend.new(options[:address], options[:messages])).run
-rescue Interrupt => error
-  puts "ERROR: #{error}"
-end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/reactor/helloworld.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/helloworld.rb b/examples/ruby/reactor/helloworld.rb
deleted file mode 100644
index 9b02e8a..0000000
--- a/examples/ruby/reactor/helloworld.rb
+++ /dev/null
@@ -1,73 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-require 'qpid_proton'
-require 'optparse'
-
-class HelloWorld < Qpid::Proton::Handler::MessagingHandler
-
-  def initialize(server, address)
-    super()
-    @server = server
-    @address = address
-  end
-
-  def on_start(event)
-    conn = event.container.connect(:address => @server)
-    event.container.create_sender(conn, :target => @address)
-    event.container.create_receiver(conn, :source => @address)
-  end
-
-  def on_sendable(event)
-    msg = Qpid::Proton::Message.new
-    msg.body = "Hello world!"
-    event.sender.send(msg)
-    event.sender.close
-  end
-
-  def on_message(event)
-    puts event.message.body
-    event.connection.close
-  end
-
-  def on_transport_error(event)
-    raise "Connection error: #{event.transport.condition}"
-  end
-end
-
-options = {
-  :address => "localhost:5672",
-  :queue => "examples"
-}
-
-OptionParser.new do |opts|
-  opts.banner = "Usage: helloworld_direct.rb [options]"
-
-  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
-    options[:address] = address
-  end
-
-  opts.on("-q", "--queue=QUEUE", "Send messages to QUEUE (def. #{options[:queue]})") do |queue|
-    options[:queue] = queue
-  end
-
-end.parse!
-
-hw = HelloWorld.new(options[:address], "examples")
-Qpid::Proton::Reactor::Container.new(hw).run

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/reactor/helloworld_direct.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/helloworld_direct.rb b/examples/ruby/reactor/helloworld_direct.rb
deleted file mode 100644
index e98cc1f..0000000
--- a/examples/ruby/reactor/helloworld_direct.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-require 'qpid_proton'
-require 'optparse'
-
-options = {
-  :address => "localhost:5672/examples",
-}
-
-class HelloWorldDirect < Qpid::Proton::Handler::MessagingHandler
-
-  include Qpid::Proton::Util::Wrapper
-
-  def initialize(url)
-    super()
-    @url = url
-  end
-
-  def on_start(event)
-    @acceptor = event.container.listen(@url)
-    event.container.create_sender(@url)
-  end
-
-  def on_sendable(event)
-    msg = Qpid::Proton::Message.new
-    msg.body = "Hello world!"
-    event.sender.send(msg)
-    event.sender.close
-  end
-
-  def on_message(event)
-    puts "#{event.message.body}"
-  end
-
-  def on_accepted(event)
-    event.connection.close
-  end
-
-  def on_connection_closed(event)
-    @acceptor.close
-  end
-
-end
-
-OptionParser.new do |opts|
-  opts.banner = "Usage: helloworld_direct.rb [options]"
-
-  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
-    options[:address] = address
-  end
-
-end.parse!
-
-begin
-  Qpid::Proton::Reactor::Container.new(HelloWorldDirect.new(options[:address])).run
-rescue Interrupt => error
-end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/reactor/server.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/server.rb b/examples/ruby/reactor/server.rb
deleted file mode 100644
index 9373272..0000000
--- a/examples/ruby/reactor/server.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-require 'qpid_proton'
-require 'optparse'
-
-class Server < Qpid::Proton::Handler::MessagingHandler
-
-  def initialize(url)
-    super()
-    @url = Qpid::Proton::URL.new url
-    @address = @url.path
-    @senders = {}
-  end
-
-  def on_start(event)
-    @container = event.container
-    @conn = @container.connect(:url => @url)
-    @receiver = @container.create_receiver(@conn, :source => @address)
-    @relay = nil
-  end
-
-  def on_connection_opened(event)
-    if event.connection.remote_offered_capabilities &&
-      event.connection.remote_offered_capabilities.contain?("ANONYMOUS-RELAY")
-      @relay = @container.create_sender(@conn, nil)
-    end
-  end
-
-  def on_message(event)
-    msg = event.message
-    puts "<- #{msg.body}"
-    sender = @relay || @senders[msg.reply_to]
-    if sender.nil?
-      sender = @container.create_sender(@conn, :target => msg.reply_to)
-      @senders[msg.reply_to] = sender
-    end
-    reply = Qpid::Proton::Message.new
-    reply.address = msg.reply_to
-    reply.body = msg.body.upcase
-    puts "-> #{reply.body}"
-    reply.correlation_id = msg.correlation_id
-    sender.send(reply)
-  end
-
-  def on_transport_error(event)
-    raise "Connection error: #{event.transport.condition}"
-  end
-end
-
-options = {
-  :address => "localhost:5672/examples",
-}
-
-OptionParser.new do |opts|
-  opts.banner = "Usage: server.rb [options]"
-  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") { |address| options[:address] = address }
-end.parse!
-
-Qpid::Proton::Reactor::Container.new(Server.new(options[:address])).run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/reactor/simple_recv.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/simple_recv.rb b/examples/ruby/reactor/simple_recv.rb
deleted file mode 100644
index 55a37ee..0000000
--- a/examples/ruby/reactor/simple_recv.rb
+++ /dev/null
@@ -1,58 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-require 'qpid_proton'
-require 'optparse'
-
-require_relative '../lib/send_and_receive'
-
-class Receiver < ExampleReceive
-
-  def initialize(url, count)
-    super(url, count)
-  end
-
-  def on_start(event)
-    event.container.create_receiver(@url)
-  end
-
-end
-
-options = {
-  :address => "localhost:5672/examples",
-  :messages => 100,
-}
-
-OptionParser.new do |opts|
-  opts.banner = "Usage: simple_send.rb [options]"
-
-  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
-    options[:address] = address
-  end
-
-  opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
-    OptionParser::DecimalInteger) do |messages|
-    options[:messages] = messages
-  end
-end.parse!
-
-begin
-  Qpid::Proton::Reactor::Container.new(Receiver.new(options[:address], options[:messages])).run
-rescue Interrupt
-end

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/reactor/simple_send.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/reactor/simple_send.rb b/examples/ruby/reactor/simple_send.rb
deleted file mode 100644
index 1dd4150..0000000
--- a/examples/ruby/reactor/simple_send.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-require 'qpid_proton'
-require 'optparse'
-
-require_relative '../lib/send_and_receive'
-
-options = {
-  :address => "localhost:5672/examples",
-  :messages => 100,
-}
-
-class SimpleSend < ExampleSend
-
-  def initialize(url, messages)
-    super(url, messages)
-  end
-
-  def on_start(event)
-    event.container.create_sender(url)
-  end
-
-end
-
-OptionParser.new do |opts|
-  opts.banner = "Usage: simple_send.rb [options]"
-
-  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
-    options[:address] = address
-  end
-
-  opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
-    OptionParser::DecimalInteger) do |messages|
-    options[:messages] = messages
-  end
-end.parse!
-
-Qpid::Proton::Reactor::Container.new(SimpleSend.new(options[:address], options[:messages])).run

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/registry_test.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/registry_test.rb b/examples/ruby/registry_test.rb
deleted file mode 100644
index b4b1f6c..0000000
--- a/examples/ruby/registry_test.rb
+++ /dev/null
@@ -1,76 +0,0 @@
-#--
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#++
-
-require 'qpid_proton'
-require 'weakref'
-
-def show_registry(registry)
-  registry.each_pair do |key, value|
-    registry.delete(key) if value.weakref_alive?
-  end
-  puts "The contents of the registry: size=#{registry.size}"
-end
-
-def show_object_count(clazz)
-  puts "There are #{ObjectSpace.each_object(clazz).count} instances of #{clazz}."
-end
-
-impl = Cproton.pn_transport
-implclazz = impl.class
-transport = Qpid::Proton::Transport.wrap(impl)
-
-puts "Initial setup:"
-show_object_count(Qpid::Proton::Transport)
-show_object_count(implclazz)
-
-transport = nil
-
-show_registry(Qpid::Proton.registry)
-
-ObjectSpace.garbage_collect
-
-puts "After garbage collection:"
-show_object_count(Qpid::Proton::Transport)
-show_object_count(implclazz)
-
-MAXCOUNT=100000
-(1..MAXCOUNT).each do |which|
-  nimpl = Cproton.pn_transport
-  Cproton.pn_incref(nimpl)
-  transport = Qpid::Proton::Transport.wrap(nimpl)
-  transport = Qpid::Proton::Transport.wrap(nimpl)
-end
-
-transport = nil
-
-puts "After creating #{MAXCOUNT} instances"
-show_object_count(Qpid::Proton::Transport)
-show_object_count(implclazz)
-show_registry(Qpid::Proton.registry)
-
-ObjectSpace.garbage_collect
-
-transport = Qpid::Proton::Transport.wrap(impl)
-
-puts "After garbage collection:"
-puts "impl=#{impl}"
-puts "transport=#{transport}"
-show_object_count(Qpid::Proton::Transport)
-show_object_count(implclazz)
-show_registry(Qpid::Proton.registry)

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/server.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/server.rb b/examples/ruby/server.rb
new file mode 100644
index 0000000..9373272
--- /dev/null
+++ b/examples/ruby/server.rb
@@ -0,0 +1,76 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+class Server < Qpid::Proton::Handler::MessagingHandler
+
+  def initialize(url)
+    super()
+    @url = Qpid::Proton::URL.new url
+    @address = @url.path
+    @senders = {}
+  end
+
+  def on_start(event)
+    @container = event.container
+    @conn = @container.connect(:url => @url)
+    @receiver = @container.create_receiver(@conn, :source => @address)
+    @relay = nil
+  end
+
+  def on_connection_opened(event)
+    if event.connection.remote_offered_capabilities &&
+      event.connection.remote_offered_capabilities.contain?("ANONYMOUS-RELAY")
+      @relay = @container.create_sender(@conn, nil)
+    end
+  end
+
+  def on_message(event)
+    msg = event.message
+    puts "<- #{msg.body}"
+    sender = @relay || @senders[msg.reply_to]
+    if sender.nil?
+      sender = @container.create_sender(@conn, :target => msg.reply_to)
+      @senders[msg.reply_to] = sender
+    end
+    reply = Qpid::Proton::Message.new
+    reply.address = msg.reply_to
+    reply.body = msg.body.upcase
+    puts "-> #{reply.body}"
+    reply.correlation_id = msg.correlation_id
+    sender.send(reply)
+  end
+
+  def on_transport_error(event)
+    raise "Connection error: #{event.transport.condition}"
+  end
+end
+
+options = {
+  :address => "localhost:5672/examples",
+}
+
+OptionParser.new do |opts|
+  opts.banner = "Usage: server.rb [options]"
+  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") { |address| options[:address] = address }
+end.parse!
+
+Qpid::Proton::Reactor::Container.new(Server.new(options[:address])).run()

http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/3d258158/examples/ruby/simple_recv.rb
----------------------------------------------------------------------
diff --git a/examples/ruby/simple_recv.rb b/examples/ruby/simple_recv.rb
new file mode 100644
index 0000000..47b21ed
--- /dev/null
+++ b/examples/ruby/simple_recv.rb
@@ -0,0 +1,69 @@
+#--
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#++
+
+require 'qpid_proton'
+require 'optparse'
+
+class Receiver < Qpid::Proton::Handler::MessagingHandler
+
+  def initialize(url, count)
+    super()
+    @url = url
+    @expected = count
+    @received = 0
+  end
+
+  def on_start(event)
+    event.container.create_receiver(@url)
+  end
+
+  def on_message(event)
+    if @expected.zero? || (@received < @expected)
+      puts "Received: #{event.message.body}"
+      @received = @received + 1
+      if @received == @expected
+        event.connection.close
+      end
+    end
+  end
+
+end
+
+options = {
+  :address => "localhost:5672/examples",
+  :messages => 100,
+}
+
+OptionParser.new do |opts|
+  opts.banner = "Usage: simple_send.rb [options]"
+
+  opts.on("-a", "--address=ADDRESS", "Send messages to ADDRESS (def. #{options[:address]}).") do |address|
+    options[:address] = address
+  end
+
+  opts.on("-m", "--messages=COUNT", "The number of messages to send (def. #{options[:messages]}",
+    OptionParser::DecimalInteger) do |messages|
+    options[:messages] = messages
+  end
+end.parse!
+
+begin
+  Qpid::Proton::Reactor::Container.new(Receiver.new(options[:address], options[:messages])).run
+rescue Interrupt
+end


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org