public async Task Timeout() { var theOptions = new OptionsWrapper <RabbitMQOptions>(RabbitMQOptions.Default); var thePublisher = new RabbitMQIntegrationRequestPublisher(theOptions); // Request handler registrieren var theServiceCollection = new ServiceCollection(); theServiceCollection.AddIntegrationRequestHandler(typeof(MyDelayRequestHandler)); ServiceProvider theServiceProvider = theServiceCollection.BuildServiceProvider(); var theSubscriber = new RabbitMQIntegrationRequestSubscriber(theOptions, theServiceProvider); ISubscription theSubscription = await theSubscriber.SubscribeAsync <MyRequest, MyReply>(); // Einen Request senden Assert.ThrowsAsync <TimeoutException>(async() => { await thePublisher.PublishAsync <MyRequest, MyReply>(new MyRequest { Number = 5 }, timeoutSeconds: 1); }); theSubscription.Cancel(); theSubscriber.Dispose(); thePublisher.Dispose(); }
public async Task RequestAndReplies() { var theOptions = new OptionsWrapper <RabbitMQOptions>(RabbitMQOptions.Default); var thePublisher = new RabbitMQIntegrationRequestPublisher(theOptions); // Request handler registrieren var theServiceCollection = new ServiceCollection(); theServiceCollection.AddIntegrationRequestHandler(typeof(MyRequestHandler)); ServiceProvider theServiceProvider = theServiceCollection.BuildServiceProvider(); var theSubscriber = new RabbitMQIntegrationRequestSubscriber(theOptions, theServiceProvider); ISubscription theSubscription = await theSubscriber.SubscribeAsync <MyRequest, MyReply>(topic : "MyTopic"); // Einen Request senden MyReply theReply = await thePublisher.PublishAsync <MyRequest, MyReply>(new MyRequest { Topic = "MyTopic", Number = 5 }); Assert.That(theReply.DoubledNumber, Is.EqualTo(10)); theSubscription.Cancel(); theSubscriber.Dispose(); thePublisher.Dispose(); }