public ReceivedTransportMessage ReceiveMessage() { ReceivedTransportMessage temp; if (messageQueue.TryDequeue(out temp)) { if (Transaction.Current != null) { // simulate that delivery was rolled back by putting the message back var txHook = new TxHook() .OnRollback(() => { Console.WriteLine("Returning {0} to the fake message queue", temp); messageQueue.Enqueue(temp); }); Transaction.Current.EnlistVolatile(txHook, EnlistmentOptions.None); } return temp; } return null; }
public ReceivedTransportMessage ReceiveMessage() { ReceivedTransportMessage temp; if (messageQueue.TryDequeue(out temp)) { if (Transaction.Current != null) { // simulate that delivery was rolled back by putting the message back var txHook = new TxHook() .OnRollback(() => { Console.WriteLine("Returning {0} to the fake message queue", temp); messageQueue.Enqueue(temp); }); Transaction.Current.EnlistVolatile(txHook, EnlistmentOptions.None); } return(temp); } return(null); }