Change publisher index. Publisher index is incremented by 1 after each Basic.Publish starting at 1. This is done on both client and server, hence this acknowledged messages can be matched via its delivery-tag.
@api private
# File lib/amq/client/async/extensions/rabbitmq/confirm.rb, line 198 198: def self.included(host) 199: host.handle(Protocol::Confirm::SelectOk) do |connection, frame| 200: method = frame.decode_payload 201: channel = connection.channels[frame.channel] 202: channel.handle_select_ok(method) 203: end 204: 205: host.handle(Protocol::Basic::Ack) do |connection, frame| 206: method = frame.decode_payload 207: channel = connection.channels[frame.channel] 208: channel.handle_basic_ack(method) 209: end 210: 211: host.handle(Protocol::Basic::Nack) do |connection, frame| 212: method = frame.decode_payload 213: channel = connection.channels[frame.channel] 214: channel.handle_basic_nack(method) 215: end 216: end
Turn on confirmations for this channel and, if given, register callback for Confirm.Select-Ok.
@raise [RuntimeError] Occurs when confirmations are already activated. @raise [RuntimeError] Occurs when nowait is true and block is given.
@param [Boolean] nowait Whether we expect Confirm.Select-Ok to be returned by the broker or not. @yield [method] Callback which will be executed once we receive Confirm.Select-Ok. @yieldparam [AMQ::Protocol::Confirm::SelectOk] method Protocol method class instance.
@return [self] self.
@see #
# File lib/amq/client/async/extensions/rabbitmq/confirm.rb, line 101 101: def confirm_select(nowait = false, &block) 102: if nowait && block 103: raise ArgumentError, "confirm.select with nowait = true and a callback makes no sense" 104: end 105: 106: @uses_publisher_confirmations = true 107: reset_publisher_index! 108: 109: self.redefine_callback(:confirm_select, &block) unless nowait 110: self.redefine_callback(:after_publish) do 111: increment_publisher_index! 112: end 113: @connection.send_frame(Protocol::Confirm::Select.encode(@id, nowait)) 114: 115: self 116: end
Handler for Basic.Ack. By default, it just executes hook specified via the # method with a single argument, a protocol method class instance (an instance of AMQ::Protocol::Basic::Ack).
@api plugin
# File lib/amq/client/async/extensions/rabbitmq/confirm.rb, line 175 175: def handle_basic_ack(method) 176: self.exec_callback(:ack, method) 177: end
Handler for Basic.Nack. By default, it just executes hook specified via the # method with a single argument, a protocol method class instance (an instance of AMQ::Protocol::Basic::Nack).
@api plugin
# File lib/amq/client/async/extensions/rabbitmq/confirm.rb, line 186 186: def handle_basic_nack(method) 187: self.exec_callback(:nack, method) 188: end
Handler for Confirm.Select-Ok. By default, it just executes hook specified via the # method with a single argument, a protocol method class instance (an instance of AMQ::Protocol::Confirm::SelectOk) and then it deletes the callback, since Confirm.Select is supposed to be sent just once.
@api plugin
# File lib/amq/client/async/extensions/rabbitmq/confirm.rb, line 165 165: def handle_select_ok(method) 166: self.exec_callback_once(:confirm_select, method) 167: end
This method is executed after publishing of each message via {Exchage#publish}. Currently it just increments publisher index by 1, so messages can be actually matched.
@api plugin
# File lib/amq/client/async/extensions/rabbitmq/confirm.rb, line 84 84: def increment_publisher_index! 85: @publisher_index += 1 86: end
Turn on confirmations for this channel and, if given, register callback for basic.ack from the broker.
@raise [RuntimeError] Occurs when confirmations are already activated. @raise [RuntimeError] Occurs when nowait is true and block is given. @param [Boolean] nowait Whether we expect Confirm.Select-Ok to be returned by the broker or not.
@yield [basick_ack] Callback which will be executed every time we receive Basic.Ack from the broker. @yieldparam [AMQ::Protocol::Basic::Ack] basick_ack Protocol method class instance.
@return [self] self.
# File lib/amq/client/async/extensions/rabbitmq/confirm.rb, line 135 135: def on_ack(nowait = false, &block) 136: self.use_publisher_confirmations! unless self.uses_publisher_confirmations? 137: 138: self.define_callback(:ack, &block) if block 139: 140: self 141: end
Register error callback for Basic.Nack. It’s called when message(s) is rejected.
@return [self] self
# File lib/amq/client/async/extensions/rabbitmq/confirm.rb, line 148 148: def on_nack(&block) 149: self.define_callback(:nack, &block) if block 150: 151: self 152: end
Publisher index is an index of the last message since the confirmations were activated, started with 0. It’s incremented by 1 every time a message is published. This is done on both client and server, hence this acknowledged messages can be matched via its delivery-tag.
@return [Integer] Current publisher index. @api public
# File lib/amq/client/async/extensions/rabbitmq/confirm.rb, line 67 67: def publisher_index 68: @publisher_index ||= 0 69: end
Resets publisher index to 0
@api plugin
# File lib/amq/client/async/extensions/rabbitmq/confirm.rb, line 74 74: def reset_publisher_index! 75: @publisher_index = 0 76: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.