public static IEnumerable <TransportMessage> GetMessages(this SqlServerTransport transport) { var messages = new List <TransportMessage>(); AsyncHelpers.RunSync(async() => { while (true) { using (var scope = new RebusTransactionScope()) { var transportMessage = await transport.Receive(scope.TransactionContext, CancellationToken.None); if (transportMessage == null) { break; } messages.Add(transportMessage); await scope.CompleteAsync(); } } }); return(messages); }
public async Task ReceivesSentMessageWhenTransactionIsCommitted() { using (var scope = new RebusTransactionScope()) { await _transport.Send(QueueName, RecognizableMessage(), scope.TransactionContext); await scope.CompleteAsync(); } using (var scope = new RebusTransactionScope()) { var transportMessage = await _transport.Receive(scope.TransactionContext, _cancellationToken); await scope.CompleteAsync(); AssertMessageIsRecognized(transportMessage); } }
public async Task ReceivesSentMessageWhenTransactionIsCommitted() { using (var context = new DefaultTransactionContext()) { await _transport.Send(QueueName, RecognizableMessage(), context); await context.Complete(); } using (var context = new DefaultTransactionContext()) { var transportMessage = await _transport.Receive(context); await context.Complete(); AssertMessageIsRecognized(transportMessage); } }