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/18 16:03:38 UTC
[31/50] qpid-proton git commit: PROTON-781: Added
OutgoingMessageHandler to the Ruby reactive APIs.
PROTON-781: Added OutgoingMessageHandler to the Ruby reactive APIs.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo
Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/13789804
Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/13789804
Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/13789804
Branch: refs/heads/PROTON-781-ruby-reactor-apis
Commit: 137898046f9089a873b1f3a0f9b7b504b494fa59
Parents: e165313
Author: Darryl L. Pierce <mc...@gmail.com>
Authored: Thu Feb 26 09:59:18 2015 -0500
Committer: Darryl L. Pierce <mc...@gmail.com>
Committed: Thu Jun 18 09:27:20 2015 -0400
----------------------------------------------------------------------
.../lib/handler/outgoing_message_handler.rb | 98 ++++++++++++++++++++
proton-c/bindings/ruby/lib/qpid_proton.rb | 1 +
2 files changed, 99 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/13789804/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb b/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb
new file mode 100644
index 0000000..056a131
--- /dev/null
+++ b/proton-c/bindings/ruby/lib/handler/outgoing_message_handler.rb
@@ -0,0 +1,98 @@
+#--
+# 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 Qpid::Proton::Handler
+
+ # A utility for simpler and more intuitive handling of delivery events
+ # related to outgoing messages.
+ #
+ class OutgoingMessageHandler < Qpid::Proton::BaseHandler
+
+ def initialize(auto_settle = true, delegate = nil)
+ @auto_settle = auto_settle
+ @delegate = delegate
+ end
+
+ def on_link_flow(event)
+ self.on_sendable(event) if event.link.sender? && event.link.credit > 0
+ end
+
+ def on_delivery(event)
+ delivery = event.delivery
+ if delivery.link.sender? && delivery.updated?
+ if delivery.remote_accepted?
+ self.on_accepted(event)
+ elsif delivery.remote_rejected?
+ self.on_rejected(event)
+ elsif delivery.remote_released? || delivery.remote_modified?
+ self.on_released(event)
+ end
+ self.on_settled(event) if delivery.settled?
+ delivery.settle if @auto_settle
+ end
+ end
+
+ # Called when the sender link has credit and messages and be transferred.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_sendable(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_sendable, event) if !@delegate.nil?
+ end
+
+ # Called when the remote peer accepts a sent message.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_accepted(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_accepted, event) if !@delegate.nil?
+ end
+
+ # Called when the remote peer rejects a sent message.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_rejected(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_rejected, event) if !@delegate.nil?
+ end
+
+ # Called when the remote peer releases an outgoing message.
+ #
+ # Note that this may be in resposnse to either the REELAASE or MODIFIED
+ # state as defined by the AMQP specification.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_released(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_released, event) if !@delegate.nil?
+ end
+
+ # Called when the remote peer has settled the outgoing message.
+ #
+ # This is the point at which it should never be retransmitted.
+ #
+ # @param event [Qpid::Proton::Event::Event] The event.
+ #
+ def on_settled(event)
+ Qpid::Proton::Event.dispatch(@delegate, :on_settled, event) if !@delegate.nil?
+ end
+
+ end
+
+end
http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/13789804/proton-c/bindings/ruby/lib/qpid_proton.rb
----------------------------------------------------------------------
diff --git a/proton-c/bindings/ruby/lib/qpid_proton.rb b/proton-c/bindings/ruby/lib/qpid_proton.rb
index 1fbf710..5c2e1bc 100644
--- a/proton-c/bindings/ruby/lib/qpid_proton.rb
+++ b/proton-c/bindings/ruby/lib/qpid_proton.rb
@@ -88,6 +88,7 @@ require "handler/wrapped_handler"
require "handler/acking"
require "handler/endpoint_state_handler"
require "handler/incoming_message_handler"
+require "handler/outgoing_message_handler"
require "handler/c_flow_controller"
module Qpid::Proton
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org