Permalink
Browse files

Added transaction scope options back to the transport for MSMQ

  • Loading branch information...
1 parent b0a282e commit 599a4c1357100d84d430dda5c559321333603a72 @phatboyg phatboyg committed Aug 16, 2011
Showing with 13 additions and 10 deletions.
  1. +13 −10 src/Transports/MassTransit.Transports.Msmq/TransactionalInboundMsmqTransport.cs
@@ -40,14 +40,6 @@ public override void Receive(Func<IReceiveContext, Action<IReceiveContext>> call
{
try
{
- var options = new TransactionOptions
- {
- IsolationLevel = _isolationLevel,
- Timeout = _transactionTimeout,
- };
-
- // TODO well shit, if we can't control the transaction scope, we need a new plan
-
EnumerateQueue(callback, timeout);
}
catch (MessageQueueException ex)
@@ -60,9 +52,20 @@ public override void Receive(Func<IReceiveContext, Action<IReceiveContext>> call
protected override void ReceiveMessage(MessageEnumerator enumerator, TimeSpan timeout,
Action<Message> receiveAction)
{
- using (var message = enumerator.RemoveCurrent(timeout, MessageQueueTransactionType.Automatic))
+ var options = new TransactionOptions
+ {
+ IsolationLevel = _isolationLevel,
+ Timeout = _transactionTimeout,
+ };
+
+ using (var scope = new TransactionScope(TransactionScopeOption.Required, options))
{
- receiveAction(message);
+ using (Message message = enumerator.RemoveCurrent(timeout, MessageQueueTransactionType.Automatic))
+ {
+ receiveAction(message);
+ }
+
+ scope.Complete();
}
}
}

0 comments on commit 599a4c1

Please sign in to comment.