Guest User

Untitled

a guest
Jul 20th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. Index: mq.rb
  2. ===================================================================
  3. --- mq.rb (revision 13616)
  4. +++ mq.rb (working copy)
  5. @@ -221,6 +221,10 @@
  6. MQ.error "Basic.GetEmpty for invalid consumer"
  7. end
  8.  
  9. + when Protocol::Tx::CommitOk
  10. + tx_callback = (@tx_callback ||= []).shift
  11. + tx_callback.call if tx_callback
  12. +
  13. when Protocol::Channel::Close
  14. raise Error, "#{method.reply_text} in #{Protocol.classes[method.class_id].methods[method.method_id]} on #{@channel}"
  15.  
  16. @@ -736,6 +740,18 @@
  17. send Protocol::Basic::Qos.new(:prefetch_size => 0, :prefetch_count => size, :global => false)
  18. end
  19.  
  20. + def transaction(block, commit_callback)
  21. + send Protocol::Tx::Select.new
  22. + begin
  23. + block.call
  24. + (@tx_callback ||= []) << commit_callback
  25. + send Protocol::Tx::Commit.new
  26. + rescue Object
  27. + send Protocol::Tx::Rollback.new
  28. + raise
  29. + end
  30. + end
  31. +
  32. # Returns a hash of all the exchange proxy objects.
  33. #
  34. # Not typically called by client code.
Add Comment
Please, Sign In to add comment