PROTON-781: Added the Acking mixin to the Ruby reactive APIs. The Acking mixin provides methods for handling the settling of messages based on reactive callbacks.
Project: http://git-wip-us.apache.org/repos/asf/qpid-proton/repo Commit: http://git-wip-us.apache.org/repos/asf/qpid-proton/commit/8d8bfd23 Tree: http://git-wip-us.apache.org/repos/asf/qpid-proton/tree/8d8bfd23 Diff: http://git-wip-us.apache.org/repos/asf/qpid-proton/diff/8d8bfd23 Branch: refs/heads/PROTON-781-ruby-reactor-apis Commit: 8d8bfd23257a1b3944ec2793d40eddee0409d20e Parents: 51e85ea Author: Darryl L. Pierce <mcpie...@gmail.com> Authored: Wed Feb 25 13:27:30 2015 -0500 Committer: Darryl L. Pierce <mcpie...@gmail.com> Committed: Thu Jun 18 09:27:19 2015 -0400 ---------------------------------------------------------------------- proton-c/bindings/ruby/lib/handler/acking.rb | 70 +++++++++++++++++++++++ proton-c/bindings/ruby/lib/qpid_proton.rb | 1 + 2 files changed, 71 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8d8bfd23/proton-c/bindings/ruby/lib/handler/acking.rb ---------------------------------------------------------------------- diff --git a/proton-c/bindings/ruby/lib/handler/acking.rb b/proton-c/bindings/ruby/lib/handler/acking.rb new file mode 100644 index 0000000..2c94cfe --- /dev/null +++ b/proton-c/bindings/ruby/lib/handler/acking.rb @@ -0,0 +1,70 @@ +#-- +# 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 + + # Mixing that provides methods for acknowledging a delivery. + # + module Acking + + # Accept the receivered message. + # + # @param delivery [Qpid::Proton::Delivery] The delivery. + # + def accept(delivery) + self.settle(delivery, Qpid::Proton::Delivery::ACCEPTED) + end + + # Rejects a received message that is considered invalid or unprocessable. + # + # @param delivery [Qpid::Proton::Delivery] The delivery. + # + def reject(delivery) + self.settle(delivery, Qpid::Proton::Delivery::REJECTED) + end + + # Releases a received message, making it available at the source for any + # other interested receiver. + # + # @param delivery [Qpid::Proton::Delivery] The delivery + # @param delivered [Boolean] True if this was considered a delivery + # attempt. + # + def release(delivery, delivered = true) + if delivered + self.settle(delivery, Qpid::Proton::Delivery::MODIFIED) + else + self.settle(delivery, Qpid::Proton::Delivery::RELEASED) + end + end + + # Settles the specified delivery. Updates the delivery state if a state + # is specified. + # + # @param delivery [Qpid::Proton::Delivery] The delivery. + # @param state [Fixnum] The delivery state. + # + def settle(delivery, state = nil) + delivery.update(state) unless state.nil? + delivery.settle + end + + end + +end http://git-wip-us.apache.org/repos/asf/qpid-proton/blob/8d8bfd23/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 a4b3391..8db28f3 100644 --- a/proton-c/bindings/ruby/lib/qpid_proton.rb +++ b/proton-c/bindings/ruby/lib/qpid_proton.rb @@ -84,6 +84,7 @@ require "messenger/messenger" # Handler classes require "handler/c_adaptor" require "handler/wrapped_handler" +require "handler/acking" module Qpid::Proton # @private --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org