Пример #1
0
        [Test, Timeout(10000)]//, Ignore("too slow to run every time")]
        public async Task can_route_many()
        {
            using (var router = new TransactionalRouter(inputQueueFormatName, sender, Route))
            {
                for (int i = 0; i < 1000; i++)
                {
                    input.Write(new Message {
                        Label = "1", AppSpecific = i
                    }, QueueTransaction.Single);
                    input.Write(new Message {
                        Label = "2", AppSpecific = i
                    }, QueueTransaction.Single);
                }
                var sw = new Stopwatch();
                sw.Start();
                await sender.StartAsync();

                try
                {
                    var rtask = router.StartAsync();
                    for (int i = 0; i < 1000; i++)
                    {
                        var got = outRead1.Read();
                        Assert.AreEqual("1", got.Label, "Label");
                        Assert.AreEqual(i, got.AppSpecific, "AppSpecific");
                        got = outRead2.Read();
                        Assert.AreEqual("2", got.Label, "Label");
                        Assert.AreEqual(i, got.AppSpecific, "AppSpecific");
                    }
                    sw.Stop();
                }
                finally
                {
                    await router?.StopAsync();

                    await sender.StopAsync();
                }
                Console.WriteLine($"Reading 2000 routed messages took {sw.ElapsedMilliseconds:N0} MS");
            }
        }
Пример #2
0
        public async Task can_route_transactional_to_other_queue()
        {
            using (var router = new TransactionalRouter(inputQueueFormatName, sender, Route))
            {
                await sender.StartAsync();

                try
                {
                    var rtask = router.StartAsync();
                    input.Write(new Message {
                        Label = "2", AppSpecific = 1
                    }, QueueTransaction.Single);
                    var got = outRead2.Read();
                    Assert.AreEqual("2", got.Label);
                }
                finally
                {
                    await router?.StopAsync();

                    await sender.StopAsync();
                }
            }
        }