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); }
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(); }
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"); } }