public async Task WhenCoreHeadersShouldBeCollapsed_ThenHeadersAreConcatenatedIntoOneAttribute() { //arrange var inputqueueName = TestConfig.GetName($"inputQueue-{DateTime.Now.Ticks}"); var inputQueue = _transportFactory.Create(inputqueueName); var outputqueueName = TestConfig.GetName($"outputQueue-{DateTime.Now.Ticks}"); var outputQueue = _transportFactory.Create(outputqueueName); await WithContext(async context => { var transportMessage = MessageWith("hej"); Assert.That(transportMessage.Headers.ContainsKey(Headers.MessageId)); Assert.That(transportMessage.Headers.ContainsKey(Headers.CorrelationId)); // send the message of to the bus, which will make sure that all core headers // are collapsed into a single header 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"); // inspect the message whether it contains the original headers which are now again exploded Assert.That(transportMessage.Headers.ContainsKey(Headers.MessageId)); Assert.That(transportMessage.Headers.ContainsKey(Headers.CorrelationId)); }); }
public void WhenUsingAQueuNameWithSlash_ThenArgumentExcetiopIsThrown() { //arrange var invalidQueueName = "/inputqueue"; Assert.Throws <ArgumentException>(() => _transportFactory.Create(invalidQueueName)); //act //assert }
public async void WhenMessageVisibilityIsRenewed_ThenItsNotVisibleForOthers() { //arrange var peeklockDuration = TimeSpan.FromSeconds(3); var transportFactory = new AmazonSqsTransportFactory(); var inputqueueName = TestConfig.QueueName("inputQueue"); var inputQueue = transportFactory.Create(inputqueueName, peeklockDuration); var inputqueueName2 = TestConfig.QueueName("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"); }); }); }
public async void WhenMessageVisibilityIsRenewed_ThenItsNotVisibleForOthers() { //arrange var peeklockDuration = TimeSpan.FromSeconds(3); var transportFactory = new AmazonSqsTransportFactory(); var inputqueueName = TestConfig.QueueName("inputQueue"); var inputQueue = transportFactory.Create(inputqueueName, peeklockDuration); var inputqueueName2 = TestConfig.QueueName("outputQueue"); var outputQueue = transportFactory.Create(inputqueueName2); await WithContext(async context => { await outputQueue.Send(inputqueueName, MessageWith("hej"), context); }); await WithContext(async context => { var transportMessage = await inputQueue.Receive(context); 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); Assert.That(innerMessage, Is.Null, "Did not expect to receive a message here because its peek lock should have been renewed automatically"); }); }); }