public async Task CanRoundtripSingleMessageWithBus() { var brilliantQueueName = TestConfig.GetName("roundtrippin-single-bus"); var transport = AmazonSqsTransportFactory.CreateTransport(brilliantQueueName, TimeSpan.FromSeconds(30)); Using(transport); using (var activator = new BuiltinHandlerActivator()) { var gotTheMessage = new ManualResetEvent(false); activator.Handle <string>(async message => { gotTheMessage.Set(); }); Configure.With(activator) .Transport(t => t.Register(c => transport)) .Start(); await activator.Bus.SendLocal("HAIIIIIIIIIIIIIIIIII!!!!111"); gotTheMessage.WaitOrDie(TimeSpan.FromSeconds(5)); } }
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 Task CanRoundtripSingleMessageWithTransport() { var queueName = TestConfig.GetName("roundtrippin-single"); var transport = AmazonSqsTransportFactory.CreateTransport(queueName, TimeSpan.FromSeconds(30)); Using(transport); const string positiveGreeting = "hej meeeeed dig min vennnnn!!!!!!111"; var transportMessage = new TransportMessage(NewFineHeaders(), Encoding.UTF8.GetBytes(positiveGreeting)); using (var scope = new RebusTransactionScope()) { Console.WriteLine($"Sending message to '{queueName}'"); await transport.Send(queueName, transportMessage, scope.TransactionContext); await scope.CompleteAsync(); } var receivedMessage = await transport.WaitForNextMessage(); Assert.That(Encoding.UTF8.GetString(receivedMessage.Body), Is.EqualTo(positiveGreeting)); }
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"); }); }); }
protected override void SetUp() { _brilliantQueueName = TestConfig.GetName("roundtrippin"); _transport = AmazonSqsTransportFactory.CreateTransport(_brilliantQueueName, TimeSpan.FromSeconds(30)); _transport.Purge(); }
protected override void SetUp() { _transportFactory = new AmazonSqsTransportFactory(); }
protected override void SetUp() { base.SetUp(); _transportFactory = new AmazonSqsTransportFactory(); }