Esempio n. 1
0
        public async Task Should_fault_nicely()
        {
            await Bus.Publish(new ReconnectMessage { Value = "Before" });

            bool beforeFound = await Task.Run(() => _consumer.Received.Select <ReconnectMessage>(x => x.Context.Message.Value == "Before").Any());

            Assert.IsTrue(beforeFound);

            Console.WriteLine("Okay, restart RabbitMQ");

            for (int i = 0; i < 20; i++)
            {
                await Task.Delay(1000);

                Console.Write($"{i}. ");

                IClientFactory clientFactory = await Host.CreateClientFactory(TestTimeout);

                RequestHandle <PingMessage> request = clientFactory.CreateRequest(new PingMessage());

                Response <PongMessage> response = await request.GetResponse <PongMessage>();

                await clientFactory.DisposeAsync();
            }

            Console.WriteLine("");
            Console.WriteLine("Resuming");

            await Bus.Publish(new ReconnectMessage { Value = "After" });

            bool afterFound = await Task.Run(() => _consumer.Received.Select <ReconnectMessage>(x => x.Context.Message.Value == "After").Any());

            Assert.IsTrue(afterFound);
        }
 RequestHandle <T> IClientFactory.CreateRequest <T>(T message, CancellationToken cancellationToken, RequestTimeout timeout)
 {
     return(_clientFactory.CreateRequest(message, cancellationToken, timeout));
 }
Esempio n. 3
0
 public RequestHandle <T> CreateRequest <T>(Uri destinationAddress, T message, CancellationToken cancellationToken, RequestTimeout timeout)
     where T : class
 {
     return(_clientFactory.CreateRequest(destinationAddress, message, cancellationToken, timeout));
 }