public void ShouldRead100MessagesMultiThreaded() { int expected = 100; destination.FillWith(expected); var stop = Stopwatch.StartNew(); using (var provider = new XmsConsumerProvider(false)) { var taskFactory = new TaskFactory(); var tasks = new Task[expected]; for (int i = 0; i < expected; i++) { tasks[i] = taskFactory.StartNew( () => { using(var consumer = provider.GetConsumer(destination)) { var message = consumer.ReceiveNoWait(); if (message != null) Interlocked.Increment(ref actual); } }); } Task.WaitAll(tasks.ToArray()); stop.Stop(); } Console.WriteLine("Received {0} messages multi-threaded in {1}", expected, stop.Elapsed); Assert.That(actual, Is.EqualTo(expected)); }
public void CopyExistingMessageOntoDifferentQueue_ThisProofsThatMessageDoesNotHaveSessionAfinity() { using (var producer = new XmsProducerProvider(false)) { producer.SendTestMessage(destination); } IBM.XMS.IMessage message; using (var consumer = new XmsConsumerProvider(false)) { message = consumer.GetConsumer(destination).ReceiveNoWait(); } using (var producer = new XmsProducerProvider(false)) { producer.GetProducer(Target.Error).Send(message); } }