Ejemplo n.º 1
0
        public void Setup()
        {
            inputQueueFormatName   = Queues.TryCreate(inputQueuePath, QueueTransactional.None);
            adminQueueFormatName   = Queues.TryCreate(adminQueuePath, QueueTransactional.None);
            outputQueueFormatName1 = Queues.TryCreate(outputQueuePath1, QueueTransactional.None);
            outputQueueFormatName2 = Queues.TryCreate(outputQueuePath2, QueueTransactional.None);
            deadQueueFormatName    = $"{inputQueueFormatName };Poison";

            Queues.Purge(inputQueueFormatName);
            Queues.Purge(adminQueueFormatName);

            input = new QueueWriter(inputQueueFormatName);

            dead = new QueueReader(deadQueueFormatName);
            dead.Purge();

            outRead1 = new QueueReader(outputQueueFormatName1);
            outRead1.Purge();

            outRead2 = new QueueReader(outputQueueFormatName2);
            outRead2.Purge();

            outSend1 = new QueueWriter(outputQueueFormatName1);
            outSend2 = new QueueWriter(outputQueueFormatName2);

            sender = new Postman(adminQueueFormatName);
        }
Ejemplo n.º 2
0
 public void Setup()
 {
     destFormatName  = Queues.TryCreate(destQueuePath, QueueTransactional.Transactional);
     adminFormatName = Queues.TryCreate(adminQueuePath, QueueTransactional.None);
     Queues.Purge(destFormatName);
     dest  = new QueueWriter(destFormatName);
     admin = new QueueReader(adminFormatName);
     admin.Purge();
 }
Ejemplo n.º 3
0
        public async Task can_route_many()
        {
            using (var input = new QueueWriter(testQueueFormatName))
                using (var out1 = new QueueReader(testQueueFormatName + ";one"))
                    using (var out2 = new QueueReader(testQueueFormatName + ";two"))
                        using (var router = new SubQueueRouter(testQueueFormatName, GetSubQueue))
                        {
                            out1.Purge();
                            out2.Purge();

                            for (int i = 0; i < 1000; i++)
                            {
                                input.Write(new Message {
                                    Label = "1", AppSpecific = i
                                });
                                input.Write(new Message {
                                    Label = "2", AppSpecific = i
                                });
                            }
                            var sw = new Stopwatch();
                            sw.Start();

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

                            Console.WriteLine($"Reading 2000 routed messages took {sw.ElapsedMilliseconds:N0} MS");
                        }
        }