public void ShouldSend100MessagesMultiThreadedWithTransactions()
        {
            int count = 100;
            var stop = Stopwatch.StartNew();
            using (var provider = new XmsProducerProvider(true))
            {
                var taskFactory = new TaskFactory();
                var tasks = new Task[count];

                for (int i = 0; i < count; i++)
                {
                    tasks[i] = taskFactory.StartNew(
                        () =>
                        {
                            using(var scope = new TransactionScope(TransactionScopeOption.Required))
                            {
                                provider.SendTestMessage(destination);
                                scope.Complete();
                            }
                        });
                }
                Task.WaitAll(tasks.ToArray());
                stop.Stop();
            }
            Console.WriteLine("Sent {0} messages multi-threaded in {1}", count, stop.Elapsed);
            destination.AssertMessageCount(count);
        }
Пример #2
0
        public static void FillWith(this XmsDestination destination, int count)
        {
            using (var provider = new XmsProducerProvider(false))
            {
                var taskFactory = new TaskFactory();
                var tasks = new Task[count];

                for (int i = 0; i < count; i++)
                {
                    tasks[i] = taskFactory.StartNew(() => provider.SendTestMessage(destination));
                }
                Task.WaitAll(tasks);
            }
        }
 public void ShouldSend100MessagesSingleThreaded()
 {
     int count = 100;
     var stop = Stopwatch.StartNew();
     using (var provider = new XmsProducerProvider(false))
     {
         for (int i = 0; i < count; i++)
         {
             provider.SendTestMessage(destination);
         }
     }
     Console.WriteLine("Sent {0} messages single-threaded in {1}", count, stop.Elapsed);
     destination.AssertMessageCount(count);
 }
Пример #4
0
 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);
     }
 }
        public void ShouldSend100MessagesMultiThreaded()
        {
            int count = 100;
            var stop = Stopwatch.StartNew();
            using (var provider = new XmsProducerProvider(false))
            {
                var taskFactory = new TaskFactory();
                var tasks = new Task[count];

                for (int i = 0; i < count; i++)
                {
                    tasks[i] = taskFactory.StartNew(() => provider.SendTestMessage(destination));
                }
                Task.WaitAll(tasks);
                stop.Stop();
            }
            Console.WriteLine("Sent {0} messages multi-threaded in {1}", count, stop.Elapsed);
            destination.AssertMessageCount(count);
        }
 public void SetUp()
 {
     address = TestTargets.InputQueue;
     XmsUtilities.Purge(address);
     provider = new XmsProducerProvider(true);
 }
        public void ShouldRollbackOnlyMesagesSinceLastCommit()
        {
            using (var provider = new XmsProducerProvider(true))
            {
                using (var scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    provider.SendTestMessage(destination);
                    // commit
                    scope.Complete();
                }
                using (var scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    provider.SendTestMessage(destination);
                    // roll back
                }
            }

            destination.AssertMessageCount(1);
        }
        public void Bug_AsPerIssue5()
        {
            using (var scope = new TransactionScope(TransactionScopeOption.Required))
            {
                using (var provider = new XmsProducerProvider(true))
                {
                    for (int i = 0; i < 20; i++)
                    {
                        Console.Write("Cycle {0}".FormatWith(i));

                        {
                            provider.SendTestMessage(destination);
                        }
                    }
                }
                scope.Complete();
            }
            destination.AssertMessageCount(20);
        }
        public void ShouldCommitMessageFromNonTransactionProviderEventWhenThereIsTransactionScope()
        {
            using (var provider = new XmsProducerProvider(false))
            {
                using (var scope = new TransactionScope(TransactionScopeOption.Required))
                {
                    provider.SendTestMessage(destination);
                }
            }

            destination.AssertMessageCount(1);
        }
        public void ShouldCommitMessageFromNonTransactionProvider()
        {
            using (var provider = new XmsProducerProvider(false))
            {
                provider.SendTestMessage(destination);
            }

            destination.AssertMessageCount(1);
        }
        public void ShouldCommitMessageFromTransactionProviderEventWhenThereIsNoTransactionalScope()
        {
            using (var provider = new XmsProducerProvider(true))
            {
                provider.SendTestMessage(destination);
            }

            destination.AssertMessageCount(1);
        }
Пример #12
0
        private void CreateTestMessagesUsingConcurencyWithDtc(int count)
        {
            var stop = Stopwatch.StartNew();
            using (var provider = new XmsProducerProvider(true))
            {
                var taskFactory = new TaskFactory();

                var tasks = new List<Task>();
                foreach (var i in Enumerable.Range(0, count))
                {
                    var task = taskFactory.StartNew(
                        () =>
                            {
                                using(var scope = new TransactionScope(TransactionScopeOption.Required))
                                {
                                    var producer = provider.GetProducer(destination);
                                    var msg = producer.CreateTextMessage();
                                    msg.Text = "Hello XMS message." + DateTime.Now;
                                    producer.Send(msg);
                                    scope.Complete();
                                }
                            });
                    tasks.Add(task);
                }
                Task.WaitAll(tasks.ToArray());

                var faulted = tasks.Where(x => x.IsFaulted).ToList();

                Assert.That(faulted.Count, Is.EqualTo(0));
            }
            Console.WriteLine("CreateTestMessagesUsingConcurencyWithDtc {0} messages in {1}", count, stop.Elapsed);
        }