public async Task WhenMessageVisibilityIsRenewed_ThenItsNotVisibleForOthers()
        {
            //arrange
            var peeklockDuration = TimeSpan.FromSeconds(3);

            var transportFactory = new AmazonSqsTransportFactory();
            var inputqueueName   = TestConfig.GetName("inputQueue");
            var inputQueue       = transportFactory.Create(inputqueueName, peeklockDuration);

            var inputqueueName2 = TestConfig.GetName("outputQueue");
            var outputQueue     = transportFactory.Create(inputqueueName2);

            await WithContext(async context => { await outputQueue.Send(inputqueueName, MessageWith("hej"), context); });

            var cancellationToken = new CancellationTokenSource().Token;

            await WithContext(async context =>
            {
                var transportMessage = await inputQueue.Receive(context, cancellationToken);

                Assert.That(transportMessage, Is.Not.Null, "Expected to receive the message that we just sent");

                // pretend that it takes a while to handle the message
                Thread.Sleep(6000);

                // pretend that another thread attempts to receive from the same input queue
                await WithContext(async innerContext =>
                {
                    var innerMessage = await inputQueue.Receive(innerContext, cancellationToken);

                    Assert.That(innerMessage, Is.Null, "Did not expect to receive a message here because its peek lock should have been renewed automatically");
                });
            });
        }
示例#2
0
 protected override void SetUp()
 {
     base.SetUp();
     _transportFactory = new AmazonSqsTransportFactory();
 }
示例#3
0
 public void Dispose()
 {
     AmazonSqsTransportFactory.CreateTransport(_queueName, TimeSpan.FromMinutes(5)).Purge();
 }
 protected override void SetUp()
 {
     _brilliantQueueName = TestConfig.GetName("trivialroundtrippin");
     _transport          = AmazonSqsTransportFactory.CreateTransport(_brilliantQueueName, TimeSpan.FromSeconds(30));
     _transport.Purge();
 }