lib/message_driver/adapters/bunny_adapter.rb in message-driver-0.5.3 vs lib/message_driver/adapters/bunny_adapter.rb in message-driver-0.6.0
- old
+ new
@@ -251,11 +251,11 @@
def initialize(broker, config)
validate_bunny_version
@broker = broker
@config = config
- @ack_key = Bunny::VERSION >= '1.5.0' ? :manual_ack : :ack
+ @ack_key = :manual_ack
end
attr_reader :ack_key
def connection(ensure_started = true)
@@ -336,11 +336,13 @@
fail MessageDriver::TransactionError,
"you can't finish the transaction unless you already in one!"
end
begin
if @in_confirms_transaction
- wait_for_confirms(@channel) unless @rollback_only
+ unless @rollback_only || @channel.nil?
+ @channel.wait_for_confirms
+ end
else
if is_transactional? && valid? && !@need_channel_reset && @require_commit
handle_errors do
if @rollback_only
@channel.tx_rollback
@@ -356,16 +358,10 @@
@in_confirms_transaction = false
@require_commit = false
end
end
- def wait_for_confirms(channel)
- # FIXME: make the thread-safety of this better once https://github.com/ruby-amqp/bunny/issues/227 is fixed
- channel.wait_for_confirms until channel.unconfirmed_set.empty?
- end
- private :wait_for_confirms
-
def rollback_transaction
@rollback_only = true
commit_transaction
end
@@ -534,13 +530,13 @@
rescue => e
logger.error exception_to_str(e)
end
def validate_bunny_version
- required = Gem::Requirement.create('>= 1.2.2')
+ required = Gem::Requirement.create('>= 1.7.0')
current = Gem::Version.create(Bunny::VERSION)
unless required.satisfied_by? current
- fail MessageDriver::Error, 'bunny 1.2.2 or later is required for the bunny adapter'
+ fail MessageDriver::Error, 'bunny 1.7.0 or later is required for the bunny adapter'
end
end
end
end
end