Exemplo n.º 1
0
        public ITransport Create(string inputQueueAddress)
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var asyncTaskFactory     = new TplAsyncTaskFactory(consoleLoggerFactory);

            if (inputQueueAddress == null)
            {
                var transport = new AzureServiceBusTransport(ConnectionString, null, consoleLoggerFactory, asyncTaskFactory);

                transport.Initialize();

                return(transport);
            }

            return(_queuesToDelete.GetOrAdd(inputQueueAddress, () =>
            {
                var transport = new AzureServiceBusTransport(ConnectionString, inputQueueAddress, consoleLoggerFactory, asyncTaskFactory);

                transport.PurgeInputQueue();

                transport.Initialize();

                return transport;
            }));
        }
        protected override void SetUp()
        {
            _transport = new AzureServiceBusTransport(ConnectionString, QueueName, _consoleLoggerFactory, new TplAsyncTaskFactory(_consoleLoggerFactory), new DefaultNameFormatter());

            Using(_transport);

            _transport.Initialize();
            _transport.PurgeInputQueue();

            _activator = new BuiltinHandlerActivator();

            _busStarter = Configure.With(_activator)
                          .Logging(l => l.Use(new ListLoggerFactory(outputToConsole: true, detailed: true)))
                          .Transport(t => t.UseAzureServiceBus(ConnectionString, QueueName).AutomaticallyRenewPeekLock())
                          .Options(o =>
            {
                o.SetNumberOfWorkers(1);
                o.SetMaxParallelism(1);
            })
                          .Create();

            _bus = _busStarter.Bus;

            Using(_bus);
        }
        public ITransport Create(string inputQueueAddress)
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var asyncTaskFactory = new TplAsyncTaskFactory(consoleLoggerFactory);

            if (inputQueueAddress == null)
            {
                var transport = new AzureServiceBusTransport(ConnectionString, null, consoleLoggerFactory, asyncTaskFactory);

                transport.Initialize();

                return transport;
            }

            return _queuesToDelete.GetOrAdd(inputQueueAddress, () =>
            {
                var transport = new AzureServiceBusTransport(ConnectionString, inputQueueAddress, consoleLoggerFactory, asyncTaskFactory);

                transport.PurgeInputQueue();

                transport.Initialize();

                return transport;
            });
        }
Exemplo n.º 4
0
        protected override void SetUp()
        {
            var connectionString     = AsbTestConfig.ConnectionString;
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var asyncTaskFactory     = new TplAsyncTaskFactory(consoleLoggerFactory);

            using (var transport = new AzureServiceBusTransport(connectionString, QueueName, consoleLoggerFactory, asyncTaskFactory, new DefaultNameFormatter()))
            {
                transport.PurgeInputQueue();
            }

            _activator = new BuiltinHandlerActivator();

            _busStarter = Configure.With(_activator)
                          .Transport(t => t.UseAzureServiceBus(connectionString, QueueName))
                          .Routing(r => r.TypeBased().Map <TimedMessage>(QueueName))
                          .Options(o =>
            {
                o.LogPipeline();
            })
                          .Create();

            _bus = _busStarter.Bus;

            Using(_bus);
        }
Exemplo n.º 5
0
        static AzureServiceBusTransport GetTransport()
        {
            var transport = new AzureServiceBusTransport(AzureServiceBusTransportFactory.ConnectionString, QueueName);

            transport.Initialize();
            transport.PurgeInputQueue();
            return(transport);
        }
        protected override void SetUp()
        {
            _loggerFactory = new ListLoggerFactory(outputToConsole: false);

            _deadletters = GetAsbTransport("error");
            Using(_deadletters);
            _deadletters.Initialize();

            _deadletters.PurgeInputQueue();
        }
        static void PurgeQueue(string queueName)
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var asyncTaskFactory     = new TplAsyncTaskFactory(consoleLoggerFactory);
            var connectionString     = AsbTestConfig.ConnectionString;

            using (var transport = new AzureServiceBusTransport(connectionString, queueName, consoleLoggerFactory, asyncTaskFactory, new DefaultNameFormatter()))
            {
                transport.PurgeInputQueue();
            }
        }
Exemplo n.º 8
0
        protected override void SetUp()
        {
            var loggerFactory = new ConsoleLoggerFactory(false);

            errorQueueTransport = new AzureServiceBusTransport(AsbTestConfig.ConnectionString, "error", loggerFactory, new TplAsyncTaskFactory(loggerFactory), new DefaultNameFormatter());

            Using(errorQueueTransport);

            errorQueueTransport.Initialize();
            errorQueueTransport.PurgeInputQueue();
        }
        public ITransport Create(string inputQueueAddress)
        {
            return _queuesToDelete.GetOrAdd(inputQueueAddress, () =>
            {
                var transport = new AzureServiceBusTransport(ConnectionString, inputQueueAddress);

                transport.PurgeInputQueue();

                transport.Initialize();

                return transport;
            });
        }
        public ITransport Create(string inputQueueAddress)
        {
            return(_queuesToDelete.GetOrAdd(inputQueueAddress, () =>
            {
                var transport = new AzureServiceBusTransport(ConnectionString, inputQueueAddress);

                transport.PurgeInputQueue();

                transport.Initialize();

                return transport;
            }));
        }
        ITransport GetTransport()
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var asyncTaskFactory     = new TplAsyncTaskFactory(consoleLoggerFactory);
            var connectionString     = StandardAzureServiceBusTransportFactory.ConnectionString;

            var transport = new AzureServiceBusTransport(connectionString, _queueName, consoleLoggerFactory, asyncTaskFactory);

            Using(transport);
            transport.Initialize();
            transport.PurgeInputQueue();

            return(transport);
        }
Exemplo n.º 12
0
        ITransport GetTransport()
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var asyncTaskFactory     = new TplAsyncTaskFactory(consoleLoggerFactory);
            var connectionString     = AsbTestConfig.ConnectionString;

            //var transport = new AzureServiceBusTransport(connectionString, _queueName, consoleLoggerFactory, asyncTaskFactory);
            var transport = new AzureServiceBusTransport(connectionString, _queueName, consoleLoggerFactory, asyncTaskFactory, new AzureServiceBusNameHelper());

            Using(transport);
            transport.Initialize();
            transport.PurgeInputQueue();

            return(transport);
        }
Exemplo n.º 13
0
        ITransport GetTransport()
        {
            if (_mode == AzureServiceBusMode.Basic)
            {
                var basicTransport = new BasicAzureServiceBusTransport(StandardAzureServiceBusTransportFactory.ConnectionString, _queueName, new ConsoleLoggerFactory(false));
                basicTransport.Initialize();
                basicTransport.PurgeInputQueue();
                return(basicTransport);
            }
            var transport = new AzureServiceBusTransport(StandardAzureServiceBusTransportFactory.ConnectionString, _queueName, new ConsoleLoggerFactory(false));

            Using(transport);
            transport.Initialize();
            transport.PurgeInputQueue();
            return(transport);
        }
        protected override void SetUp()
        {
            _transport = new AzureServiceBusTransport(AzureServiceBusTransportFactory.ConnectionString, QueueName);
            _transport.PurgeInputQueue();

            _activator = new BuiltinHandlerActivator();

            _bus = Configure.With(_activator)
                   .Transport(t => t.UseAzureServiceBus(AzureServiceBusTransportFactory.ConnectionString, QueueName)
                              .AutomaticallyRenewPeekLock())
                   .Options(o =>
            {
                o.SetNumberOfWorkers(1);
                o.SetMaxParallelism(1);
            })
                   .Start();

            Using(_bus);
        }
        protected override void SetUp()
        {
            _transport = new AzureServiceBusTransport(StandardAzureServiceBusTransportFactory.ConnectionString, QueueName, new ConsoleLoggerFactory(false));
            _transport.PurgeInputQueue();

            _activator = new BuiltinHandlerActivator();

            _bus = Configure.With(_activator)
                .Transport(t => t.UseAzureServiceBus(StandardAzureServiceBusTransportFactory.ConnectionString, QueueName, _azureServiceBusMode)
                .AutomaticallyRenewPeekLock())
                .Options(o =>
                {
                    o.SetNumberOfWorkers(1);
                    o.SetMaxParallelism(1);
                })
                .Start();

            Using(_bus);
        }
        protected override void SetUp()
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);

            _transport = new AzureServiceBusTransport(StandardAzureServiceBusTransportFactory.ConnectionString, QueueName, consoleLoggerFactory, new TplAsyncTaskFactory(consoleLoggerFactory));
            _transport.PurgeInputQueue();

            _activator = new BuiltinHandlerActivator();

            _bus = Configure.With(_activator)
                   .Transport(t => t.UseAzureServiceBus(StandardAzureServiceBusTransportFactory.ConnectionString, QueueName, _azureServiceBusMode)
                              .AutomaticallyRenewPeekLock())
                   .Options(o =>
            {
                o.SetNumberOfWorkers(1);
                o.SetMaxParallelism(1);
            })
                   .Start();

            Using(_bus);
        }
Exemplo n.º 17
0
        ITransport GetTransport()
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var asyncTaskFactory     = new TplAsyncTaskFactory(consoleLoggerFactory);
            var connectionString     = StandardAzureServiceBusTransportFactory.ConnectionString;
            var busLifetimeEvents    = new BusLifetimeEvents();

            if (_mode == AzureServiceBusMode.Basic)
            {
                var basicTransport = new BasicAzureServiceBusTransport(connectionString, _queueName, consoleLoggerFactory, asyncTaskFactory);
                Using(basicTransport);
                basicTransport.Initialize();
                basicTransport.PurgeInputQueue();
                return(basicTransport);
            }
            var transport = new AzureServiceBusTransport(connectionString, _queueName, consoleLoggerFactory, asyncTaskFactory);

            Using(transport);
            transport.Initialize();
            transport.PurgeInputQueue();
            return(transport);
        }
Exemplo n.º 18
0
        protected override void SetUp()
        {
            _transport = new AzureServiceBusTransport(ConnectionString, QueueName, _consoleLoggerFactory, new TplAsyncTaskFactory(_consoleLoggerFactory), new AzureServiceBusNameHelper());

            Using(_transport);

            _transport.Initialize();
            _transport.PurgeInputQueue();

            _activator = new BuiltinHandlerActivator();

            _bus = Configure.With(_activator)
                   .Transport(t => t.UseAzureServiceBus(ConnectionString, QueueName).AutomaticallyRenewPeekLock())
                   .Options(o =>
            {
                o.SetNumberOfWorkers(1);
                o.SetMaxParallelism(1);
            })
                   .Start();

            Using(_bus);
        }
        public async Task ShouldBeAbleToRecieveEvenWhenNotCreatingQueue()
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var transport            = new AzureServiceBusTransport(AsbTestConfig.ConnectionString, QueueName, consoleLoggerFactory, new TplAsyncTaskFactory(consoleLoggerFactory), new DefaultNameFormatter());

            transport.PurgeInputQueue();
            //Create the queue for the receiver since it cannot create it self beacuse of lacking rights on the namespace
            transport.CreateQueue(QueueName);

            var recieverActivator = new BuiltinHandlerActivator();
            var senderActivator   = new BuiltinHandlerActivator();

            var gotMessage = new ManualResetEvent(false);

            recieverActivator.Handle <string>(async(bus, context, message) =>
            {
                gotMessage.Set();
                Console.WriteLine("got message in readonly mode");
            });

            var receiverBus = Configure.With(recieverActivator)
                              .Logging(l => l.ColoredConsole())
                              .Transport(t =>
                                         t.UseAzureServiceBus(AsbTestConfig.ConnectionString, QueueName)
                                         .DoNotCreateQueues())
                              .Start();

            var senderBus = Configure.With(senderActivator)
                            .Transport(t => t.UseAzureServiceBus(AsbTestConfig.ConnectionString, "sender"))
                            .Start();

            Using(receiverBus);
            Using(senderBus);

            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver");

            gotMessage.WaitOrDie(TimeSpan.FromSeconds(10));
        }
        public async Task DoesntIgnoreDefinedTimeoutWhenReceiving(int operationTimeoutInSeconds)
        {
            var operationTimeout = TimeSpan.FromSeconds(operationTimeoutInSeconds);

            var connString = StandardAzureServiceBusTransportFactory.ConnectionString;
            var builder    = new ServiceBusConnectionStringBuilder(connString)
            {
                OperationTimeout = operationTimeout
            };
            var newConnString = builder.ToString();

            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var transport            = new AzureServiceBusTransport(newConnString, QueueName, consoleLoggerFactory, new TplAsyncTaskFactory(consoleLoggerFactory));

            Using(transport);

            transport.PurgeInputQueue();
            //Create the queue for the receiver since it cannot create it self beacuse of lacking rights on the namespace
            transport.CreateQueue(QueueName);

            var senderActivator = new BuiltinHandlerActivator();

            var senderBus = Configure.With(senderActivator)
                            .Transport(t => t.UseAzureServiceBus(newConnString, "sender"))
                            .Start();

            Using(senderBus);

            // queue 3 messages
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver");

            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver2");

            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver3");

            await Task.Delay(TimeSpan.FromSeconds(2)); // wait a bit to make sure the messages are queued.

            // receive 1
            using (var scope = new RebusTransactionScope())
            {
                var sw  = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(scope.TransactionContext, _cancellationToken);

                sw.Stop();
                await scope.CompleteAsync();

                msg.Should().NotBeNull();
                sw.Elapsed.Should().BeLessThan(TimeSpan.FromMilliseconds(1500));
            }

            // receive 2
            using (var scope = new RebusTransactionScope())
            {
                var sw  = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(scope.TransactionContext, _cancellationToken);

                sw.Stop();
                await scope.CompleteAsync();

                msg.Should().NotBeNull();
                sw.Elapsed.Should().BeLessThan(TimeSpan.FromMilliseconds(1500));
            }

            // receive 3
            using (var scope = new RebusTransactionScope())
            {
                var sw  = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(scope.TransactionContext, _cancellationToken);

                sw.Stop();
                await scope.CompleteAsync();

                msg.Should().NotBeNull();
                sw.Elapsed.Should().BeLessThan(TimeSpan.FromMilliseconds(1500));
            }

            // receive 4 - NOTHING
            using (var scope = new RebusTransactionScope())
            {
                var sw  = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(scope.TransactionContext, _cancellationToken);

                sw.Stop();
                await scope.CompleteAsync();

                msg.Should().BeNull();
                sw.Elapsed.Should().BeCloseTo(operationTimeout, 2000);
            }

            // put 1 more message
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver5");

            await Task.Delay(TimeSpan.FromSeconds(2)); // wait a bit to make sure the messages are queued.

            // receive 5
            using (var scope = new RebusTransactionScope())
            {
                var sw  = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(scope.TransactionContext, _cancellationToken);

                sw.Stop();
                await scope.CompleteAsync();

                msg.Should().NotBeNull();
                sw.Elapsed.Should().BeLessThan(TimeSpan.FromMilliseconds(1500));
            }

            // receive 6 - NOTHING
            using (var scope = new RebusTransactionScope())
            {
                var sw  = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(scope.TransactionContext, _cancellationToken);

                sw.Stop();
                await scope.CompleteAsync();

                msg.Should().BeNull();
                sw.Elapsed.Should().BeCloseTo(operationTimeout, 2000);
            }
        }
Exemplo n.º 21
0
 static AzureServiceBusTransport GetTransport()
 {
     var transport = new AzureServiceBusTransport(AzureServiceBusTransportFactory.ConnectionString, QueueName);
     transport.Initialize();
     transport.PurgeInputQueue();
     return transport;
 }
Exemplo n.º 22
0
        ITransport GetTransport()
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var asyncTaskFactory = new TplAsyncTaskFactory(consoleLoggerFactory);
            var connectionString = StandardAzureServiceBusTransportFactory.ConnectionString;
            var busLifetimeEvents = new BusLifetimeEvents();

            if (_mode == AzureServiceBusMode.Basic)
            {
                var basicTransport = new BasicAzureServiceBusTransport(connectionString, _queueName, consoleLoggerFactory, asyncTaskFactory, busLifetimeEvents);
                Using(basicTransport);
                basicTransport.Initialize();
                basicTransport.PurgeInputQueue();
                return basicTransport;
            }
            var transport = new AzureServiceBusTransport(connectionString, _queueName, consoleLoggerFactory, asyncTaskFactory, busLifetimeEvents);
            Using(transport);
            transport.Initialize();
            transport.PurgeInputQueue();
            return transport;
        }
 ITransport GetTransport()
 {
     if (_mode == AzureServiceBusMode.Basic)
     {
         var basicTransport = new BasicAzureServiceBusTransport(StandardAzureServiceBusTransportFactory.ConnectionString, _queueName, new ConsoleLoggerFactory(false));
         basicTransport.Initialize();
         basicTransport.PurgeInputQueue();
         return basicTransport;
     }
     var transport = new AzureServiceBusTransport(StandardAzureServiceBusTransportFactory.ConnectionString, _queueName, new ConsoleLoggerFactory(false));
     Using(transport);
     transport.Initialize();
     transport.PurgeInputQueue();
     return transport;
 }
        public async void ShouldBeAbleToRecieveEvenWhenNotCreatingQueue(AzureServiceBusMode mode)
        {
            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var transport = new AzureServiceBusTransport(StandardAzureServiceBusTransportFactory.ConnectionString, QueueName, consoleLoggerFactory, new TplAsyncTaskFactory(consoleLoggerFactory), new BusLifetimeEvents());
            transport.PurgeInputQueue();
            //Create the queue for the receiver since it cannot create it self beacuse of lacking rights on the namespace
            transport.CreateQueue(QueueName);

            var recieverActivator = new BuiltinHandlerActivator();
            var senderActivator = new BuiltinHandlerActivator();

            var receiverBus = Configure.With(recieverActivator)
                .Logging(l => l.ColoredConsole())
                .Transport(t =>
                    t.UseAzureServiceBus(StandardAzureServiceBusTransportFactory.ConnectionString, QueueName)
                        .DoNotCreateQueues())
                .Start();

            var senderBus = Configure.With(senderActivator)
                .Transport(t => t.UseAzureServiceBus(StandardAzureServiceBusTransportFactory.ConnectionString, "sender", mode))
                .Start();

            Using(receiverBus);
            Using(senderBus);

            var gotMessage = new ManualResetEvent(false);

            recieverActivator.Handle<string>(async (bus, context, message) =>
            {
                gotMessage.Set();
                Console.WriteLine("got message in readonly mode");
            });
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver");

            gotMessage.WaitOrDie(TimeSpan.FromSeconds(10));


        }
        public async Task DoesntIgnoreDefinedTimeoutWhenReceiving(int operationTimeoutInSeconds)
        {
            var operationTimeout = TimeSpan.FromSeconds(operationTimeoutInSeconds);

            var connString = AsbTestConfig.ConnectionString;

            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var transport            = new AzureServiceBusTransport(connString, QueueName, consoleLoggerFactory, new TplAsyncTaskFactory(consoleLoggerFactory), new DefaultNameFormatter());

            transport.ReceiveOperationTimeout = TimeSpan.FromSeconds(operationTimeoutInSeconds);
            Using(transport);

            transport.Initialize();

            transport.PurgeInputQueue();
            //Create the queue for the receiver since it cannot create it self beacuse of lacking rights on the namespace
            transport.CreateQueue(QueueName);

            var senderActivator = new BuiltinHandlerActivator();

            var senderBus = Configure.With(senderActivator)
                            .Transport(t => t.UseAzureServiceBus(connString, "sender"))
                            .Start();

            Using(senderBus);

            // queue 3 messages
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver");

            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver2");

            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver3");

            //await Task.Delay(TimeSpan.FromSeconds(2)); // wait a bit to make sure the messages are queued.

            // receive 1
            using (var scope = new RebusTransactionScope())
            {
                var sw  = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(scope.TransactionContext, CancellationToken.None);

                sw.Stop();
                await scope.CompleteAsync();

                Assert.That(msg, Is.Not.Null);
                Assert.That(sw.Elapsed, Is.LessThan(TimeSpan.FromMilliseconds(1500)));
            }

            // receive 2
            using (var scope = new RebusTransactionScope())
            {
                var sw  = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(scope.TransactionContext, CancellationToken.None);

                sw.Stop();
                await scope.CompleteAsync();

                Assert.That(msg, Is.Not.Null);
                Assert.That(sw.Elapsed, Is.LessThan(TimeSpan.FromMilliseconds(1500)));
            }

            // receive 3
            using (var scope = new RebusTransactionScope())
            {
                var sw  = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(scope.TransactionContext, CancellationToken.None);

                sw.Stop();
                await scope.CompleteAsync();

                Assert.That(msg, Is.Not.Null);
                Assert.That(sw.Elapsed, Is.LessThan(TimeSpan.FromMilliseconds(1500)));
            }

            // receive 4 - NOTHING
            using (var scope = new RebusTransactionScope())
            {
                var sw  = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(scope.TransactionContext, CancellationToken.None);

                sw.Stop();
                await scope.CompleteAsync();

                Assert.That(msg, Is.Null);
                Assert.That(sw.Elapsed, Is.LessThan(operationTimeout.Add(TimeSpan.FromSeconds(2))).And.GreaterThan(operationTimeout.Subtract(TimeSpan.FromSeconds(2))));
            }

            // put 1 more message
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver5");

            await Task.Delay(TimeSpan.FromSeconds(2)); // wait a bit to make sure the messages are queued.

            // receive 5
            using (var scope = new RebusTransactionScope())
            {
                var sw  = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(scope.TransactionContext, CancellationToken.None);

                sw.Stop();
                await scope.CompleteAsync();

                Assert.That(msg, Is.Not.Null);
                Assert.That(sw.Elapsed, Is.LessThan(TimeSpan.FromMilliseconds(1500)));
            }

            // receive 6 - NOTHING
            using (var scope = new RebusTransactionScope())
            {
                var sw  = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(scope.TransactionContext, CancellationToken.None);

                sw.Stop();
                await scope.CompleteAsync();

                Assert.That(msg, Is.Null);
                Assert.That(sw.Elapsed, Is.LessThan(operationTimeout.Add(TimeSpan.FromSeconds(2))).And.GreaterThan(operationTimeout.Subtract(TimeSpan.FromSeconds(2))));
            }
        }
        public async void DoesntIgnoreDefinedTimeoutWhenReceiving(AzureServiceBusMode mode, int operationTimeoutInSeconds)
        {
            var operationTimeout = TimeSpan.FromSeconds(operationTimeoutInSeconds);

            var connString = StandardAzureServiceBusTransportFactory.ConnectionString;
            var builder = new ServiceBusConnectionStringBuilder(connString)
            {
                OperationTimeout = operationTimeout
            };
            var newConnString = builder.ToString();

            var consoleLoggerFactory = new ConsoleLoggerFactory(false);
            var transport = new AzureServiceBusTransport(newConnString, QueueName, consoleLoggerFactory, new TplAsyncTaskFactory(consoleLoggerFactory), new BusLifetimeEvents());

            Using(transport);

            transport.PurgeInputQueue();
            //Create the queue for the receiver since it cannot create it self beacuse of lacking rights on the namespace
            transport.CreateQueue(QueueName);

            var senderActivator = new BuiltinHandlerActivator();

            var senderBus = Configure.With(senderActivator)
                .Transport(t => t.UseAzureServiceBus(newConnString, "sender", mode))
                .Start();

            Using(senderBus);

            // queue 3 messages
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver");
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver2");
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver3");

            await Task.Delay(TimeSpan.FromSeconds(2)); // wait a bit to make sure the messages are queued.

            // receive 1
            using (var transactionContext = new DefaultTransactionContext())
            {
                var sw = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(transactionContext);
                sw.Stop();
                await transactionContext.Complete();

                msg.Should().NotBeNull();
                sw.Elapsed.Should().BeLessThan(TimeSpan.FromMilliseconds(1500));
            }

            // receive 2
            using (var transactionContext = new DefaultTransactionContext())
            {
                var sw = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(transactionContext);
                sw.Stop();
                await transactionContext.Complete();

                msg.Should().NotBeNull();
                sw.Elapsed.Should().BeLessThan(TimeSpan.FromMilliseconds(1500));
            }

            // receive 3
            using (var transactionContext = new DefaultTransactionContext())
            {
                var sw = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(transactionContext);
                sw.Stop();
                await transactionContext.Complete();

                msg.Should().NotBeNull();
                sw.Elapsed.Should().BeLessThan(TimeSpan.FromMilliseconds(1500));
            }

            // receive 4 - NOTHING
            using (var transactionContext = new DefaultTransactionContext())
            {
                var sw = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(transactionContext);
                sw.Stop();
                await transactionContext.Complete();

                msg.Should().BeNull();
                sw.Elapsed.Should().BeCloseTo(operationTimeout, 2000);
            }

            // put 1 more message 
            await senderBus.Advanced.Routing.Send(QueueName, "message to receiver5");

            await Task.Delay(TimeSpan.FromSeconds(2)); // wait a bit to make sure the messages are queued.

            // receive 5
            using (var transactionContext = new DefaultTransactionContext())
            {
                var sw = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(transactionContext);
                sw.Stop();
                await transactionContext.Complete();

                msg.Should().NotBeNull();
                sw.Elapsed.Should().BeLessThan(TimeSpan.FromMilliseconds(1500));
            }

            // receive 6 - NOTHING
            using (var transactionContext = new DefaultTransactionContext())
            {
                var sw = System.Diagnostics.Stopwatch.StartNew();
                var msg = await transport.Receive(transactionContext);
                sw.Stop();
                await transactionContext.Complete();

                msg.Should().BeNull();
                sw.Elapsed.Should().BeCloseTo(operationTimeout, 2000);
            }
        }