lib/message_driver/client.rb in message-driver-0.2.0.rc1 vs lib/message_driver/client.rb in message-driver-0.2.0.rc2
- old
+ new
@@ -45,21 +45,25 @@
def with_message_transaction(options={}, &block)
wrapper = fetch_context_wrapper
wrapper.increment_transaction_depth
begin
- if wrapper.transaction_depth == 1 && wrapper.ctx.supports_transactions?
- wrapper.ctx.begin_transaction(options)
- begin
- yield
- wrapper.ctx.commit_transaction
- rescue
+ if wrapper.ctx.supports_transactions?
+ if wrapper.transaction_depth == 1
+ wrapper.ctx.begin_transaction(options)
begin
- wrapper.ctx.rollback_transaction
- rescue => e
- logger.error exception_to_str(e)
+ yield
+ rescue
+ begin
+ wrapper.ctx.rollback_transaction
+ rescue => e
+ logger.error exception_to_str(e)
+ end
+ raise
end
- raise
+ wrapper.ctx.commit_transaction
+ else
+ yield
end
else
logger.debug("this adapter does not support transactions")
yield
end