lib/bunny/channel.rb in bunny-2.0.0.rc1 vs lib/bunny/channel.rb in bunny-2.0.0.rc2
- old
+ new
@@ -466,26 +466,22 @@
# @see Bunny::Channel#ack
# @see Bunny::Channel#nack
# @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
# @api public
def reject(delivery_tag, requeue = false)
- guarding_against_stale_delivery_tags(delivery_tag) do
- basic_reject(delivery_tag.to_i, requeue)
- end
+ basic_reject(delivery_tag.to_i, requeue)
end
# Acknowledges a message. Acknowledged messages are completely removed from the queue.
#
# @param [Integer] delivery_tag Delivery tag to acknowledge
# @param [Boolean] multiple (false) Should all unacknowledged messages up to this be acknowledged as well?
# @see Bunny::Channel#nack
# @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
# @api public
def ack(delivery_tag, multiple = false)
- guarding_against_stale_delivery_tags(delivery_tag) do
- basic_ack(delivery_tag.to_i, multiple)
- end
+ basic_ack(delivery_tag.to_i, multiple)
end
alias acknowledge ack
# Rejects a message. A rejected message can be requeued or
# dropped by RabbitMQ. This method is similar to {Bunny::Channel#reject} but
@@ -496,13 +492,11 @@
# @param [Boolean] requeue (false) Should this message be requeued instead of dropping it?
# @see Bunny::Channel#ack
# @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
# @api public
def nack(delivery_tag, multiple = false, requeue = false)
- guarding_against_stale_delivery_tags(delivery_tag) do
- basic_nack(delivery_tag.to_i, multiple, requeue)
- end
+ basic_nack(delivery_tag.to_i, multiple, requeue)
end
# @endgroup
#
@@ -568,11 +562,11 @@
exchange_name,
routing_key,
opts[:mandatory],
false,
@connection.frame_max)
- @connection.send_frameset_without_timeout(frames, self)
+ @connection.send_frameset(frames, self)
self
end
# Synchronously fetches a message from the queue, if there are any. This method is
@@ -705,15 +699,17 @@
# ch.basic_reject(delivery_info.delivery_tag, true)
#
# @see Bunny::Channel#basic_nack
# @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
# @api public
- def basic_reject(delivery_tag, requeue)
- raise_if_no_longer_open!
- @connection.send_frame(AMQ::Protocol::Basic::Reject.encode(@id, delivery_tag, requeue))
+ def basic_reject(delivery_tag, requeue = false)
+ guarding_against_stale_delivery_tags(delivery_tag) do
+ raise_if_no_longer_open!
+ @connection.send_frame(AMQ::Protocol::Basic::Reject.encode(@id, delivery_tag, requeue))
- nil
+ nil
+ end
end
# Acknowledges a delivery (message).
#
# @param [Integer] delivery_tag Delivery tag obtained from delivery info
@@ -725,21 +721,21 @@
# conn.start
#
# ch = conn.create_channel
# q.subscribe do |delivery_info, properties, payload|
# # requeue the message
- # ch.basic_ack(delivery_info.delivery_tag)
+ # ch.basic_ack(delivery_info.delivery_tag.to_i)
# end
#
# @example Ack a message fetched via basic.get
# conn = Bunny.new
# conn.start
#
# ch = conn.create_channel
# # we assume the queue exists and has messages
# delivery_info, properties, payload = ch.basic_get("bunny.examples.queue3", :manual_ack => true)
- # ch.basic_ack(delivery_info.delivery_tag)
+ # ch.basic_ack(delivery_info.delivery_tag.to_i)
#
# @example Ack multiple messages fetched via basic.get
# conn = Bunny.new
# conn.start
#
@@ -747,20 +743,21 @@
# # we assume the queue exists and has messages
# _, _, payload1 = ch.basic_get("bunny.examples.queue3", :manual_ack => true)
# _, _, payload2 = ch.basic_get("bunny.examples.queue3", :manual_ack => true)
# delivery_info, properties, payload3 = ch.basic_get("bunny.examples.queue3", :manual_ack => true)
# # ack all fetched messages up to payload3
- # ch.basic_ack(delivery_info.delivery_tag, true)
+ # ch.basic_ack(delivery_info.delivery_tag.to_i, true)
#
# @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
- # @see #basic_ack_known_delivery_tag
# @api public
- def basic_ack(delivery_tag, multiple)
- raise_if_no_longer_open!
- @connection.send_frame(AMQ::Protocol::Basic::Ack.encode(@id, delivery_tag, multiple))
+ def basic_ack(delivery_tag, multiple = false)
+ guarding_against_stale_delivery_tags(delivery_tag) do
+ raise_if_no_longer_open!
+ @connection.send_frame(AMQ::Protocol::Basic::Ack.encode(@id, delivery_tag, multiple))
- nil
+ nil
+ end
end
# Rejects or requeues messages just like {Bunny::Channel#basic_reject} but can do so
# with multiple messages at once.
#
@@ -813,16 +810,18 @@
#
# @see http://rubybunny.info/articles/queues.html Queues and Consumers guide
# @see http://rubybunny.info/articles/extensions.html RabbitMQ Extensions guide
# @api public
def basic_nack(delivery_tag, multiple = false, requeue = false)
- raise_if_no_longer_open!
- @connection.send_frame(AMQ::Protocol::Basic::Nack.encode(@id,
- delivery_tag,
- multiple,
- requeue))
+ guarding_against_stale_delivery_tags(delivery_tag) do
+ raise_if_no_longer_open!
+ @connection.send_frame(AMQ::Protocol::Basic::Nack.encode(@id,
+ delivery_tag,
+ multiple,
+ requeue))
- nil
+ nil
+ end
end
# Registers a consumer for queue. Delivered messages will be handled with the block
# provided to this method.
#