Logo: Relish

  1. Sign up
  2. Sign in

Project: Message-driver 0.7

Publishing a Message within a Transaction

  • @bunny
Background
Given
I am connected to the broker
And
I have a destination :publish_transaction with no messages on it
Scenarios
The block completes successfully
When
I execute the following code
with_message_transaction do
  publish(:publish_transaction, "Transacted Message 1")
  publish(:publish_transaction, "Transacted Message 2")
end
Then
I expect to find the following 2 messages on :publish_transaction
body
Transacted Message 1
Transacted Message 2
An error is raised inside the block
When
I execute the following code
with_message_transaction do
  publish(:publish_transaction, "Transacted Message 1")
  raise "an error that causes a rollback"
  publish(:publish_transaction, "Transacted Message 2")
end
Then
I expect it to raise "an error that causes a rollback"
And
I expect to find no messages on :publish_transaction

Last published 12 months ago by soupmatt.