Beispiel #1
0
        static void Main(string[] args)
        {
            //NLog.Config.SimpleConfigurator.ConfigureForConsoleLogging(LogLevel.Info);

            try
            {
                ConfigExample.TestSendOnly();
                //ConfigExample.Test();
                //OracleTests.TestBasicOps();
                //OracleTests.TestDbInit();
                //OracleTests.TestSend();
                OracleTests.TestNamedQ();
                OracleTests.TestQueueOps();
                //Console.ReadLine();
                //return;
                //MongoQueue.Test1();
                //MongoQueue.TestSer();
                //MongoQueue.Test2();
                //MongoQueue.TestSagas();
                //return;
                //DelegateTest();
                //PerfTest.SendTest();
                //Console.ReadLine();
                //return;
                //SerializationTests.Test4();
                //SerializationTests.Test3();
                //turn;
                //CacheTest();
                //TransactionTest.Test1("Data Source=(local);Initial Catalog=NGinn;User Id=nginn;Password=PASS");
                //TransactionTest.Test2("Data Source=(local);Initial Catalog=NGinn;User Id=nginn;Password=PASS");
                //TransactionTest.Test3("Data Source=(local);Initial Catalog=NGinn;User Id=nginn;Password=PASS");

                //return;
                ///configure perf counters - just to see the stats in log
                //NGinnBPM.MessageBus.Perf.DefaultCounters.ConfigureFromFile("PerfCounters.xml");
                ///Map database alias to database connection string, so then you can use
                ///the alias when referring to a queue: e.g. sql://testdb1/Queue1
                Dictionary <string, string> connStrings = new Dictionary <string, string>();
                ///configure two containers with two message buses
                IWindsorContainer wc1 = ConfigureMessageBus("sql://testdb1/MQueue4", connStrings, null);

                //IWindsorContainer wc2 = ConfigureMessageBus("sql://testdb2/MQueue2", connStrings, null);


                IMessageBus mb1  = wc1.Resolve <IMessageBus>();
                string      sqid = Guid.NewGuid().ToString();
                for (var o = 0; o < 10000; o++)
                {
                    // mb1.Notify(new TestMessage1 { Id = 100000 + o });
                }
                Console.ReadLine();
                using (var ts = new TransactionScope())
                {
                    var m = new TestMessage1 {
                        Id = 9998
                    };
                    for (int i = 0; i < 100; i++)
                    {
                        mb1.Notify(m);
                    }
                    ts.Complete();
                }
                Console.WriteLine("Batch sent. Enter");
                Console.ReadLine();
                return;

                using (var ts = new TransactionScope())
                {
                    mb1.Notify(new TestMessage1 {
                    });
                    mb1.Notify(new TestMessage1 {
                        Id = 32423
                    });
                    mb1.NewMessage(new TestMessage1 {
                        Id = 101
                    }).InSequence(sqid, 0, 4).Publish();
                    mb1.NewMessage(new TestMessage1 {
                        Id = 103
                    }).InSequence(sqid, 2, 4).Publish();
                    mb1.NewMessage(new TestMessage1 {
                        Id = 102
                    }).InSequence(sqid, 1, 4).Publish();
                    mb1.NewMessage(new TestMessage1 {
                        Id = 99
                    }).SetDeliveryDate(DateTime.Now.AddSeconds(10)).Publish();
                    var m = mb1 as NGinnBPM.MessageBus.Impl.MessageBus;
                    Console.WriteLine("STATE");
                    Console.WriteLine(m.GetCurrentTransactionState());
                    ts.Complete();
                }

                Console.ReadLine();
                SagaTest(wc1);
                Console.ReadLine();
                return;

                //IMessageBus mb2 = wc1.Resolve<IMessageBus>("bus2");


                //IMessageBus mb2 = wc2.Resolve<IMessageBus>();
                //mb1.SubscribeAt("sql://testdb2/MQueue2", typeof(TestMessage1));


                //mb1.NewMessage(new TestMessage1 { Id = 2 }).Send(mb2.Endpoint);

                //using (var ts = new System.Transactions.TransactionScope())
                //{
                //    mb1.NewMessage(new TestMessage1 { Id = 111 })
                //        .SetCorrelationId("123332")
                //        .Publish();
                //    //mb1.Notify(new TestMessage1 { Id = 100 });
                //    //mb1.Send("sql://testdb2/MQueue2", new TestMessage1());
                //    ts.Complete();
                //}
                Console.ReadLine();
                return;

                ServiceClient sc = new ServiceClient();
                sc.BaseUrl = "http://localhost:9013/call/";
                sc.CallService <TestMessage1>(new TestMessage1 {
                    Id = 99
                });
                sc.CallService <TestMessage1>(new TestMessage1 {
                    Id = 100
                });

                /*mb1.NewMessage(new Ping())
                 *  .SetTTL(DateTime.Now)
                 *  .Publish();
                 * mb1.Send("sql://testdb1/MQueue2", new Ping { });
                 * mb1.Notify(new TestMessage1 { Id = 1 });
                 */
                //mb1.NewMessage(new TestMessage1()).InTransaction(mb1.CurrentMessageTransaction).Publish();
                Console.ReadLine();

                /*for (var i = 0; i < 40000; i++)
                 * {
                 *  mb1.Notify(new Pong { Id = i.ToString() });
                 * }*/
                Console.WriteLine("Done all");
                Console.ReadLine();

                /*var sid = Guid.NewGuid().ToString("N");
                 * for (int i = 10; i >= 0; i--)
                 * {
                 *  mb1.NewMessage(new Ping { Id = i.ToString() }).InSequence(sid, i, 11).Publish();
                 * }
                 * Console.ReadLine();
                 * return;*/
                //mb1.SubscribeAt("sql://testdb2/MQueue2", typeof(TestMessage1));
                //mb1.Send("sql://testdb2/MQueue2", new Ping { Id = "TEST" });

                /*
                 * IMessageBus mb2 = wc2.Resolve<IMessageBus>();
                 * for (int i = 0; i < 50; i++)
                 * {
                 *  //mb1.Send("sql://testdb2/MQueue2", new Ping { Id = "TEST" + i });
                 * }
                 *
                 * mb1.Send("sql://testdb2/MQueue2", new Ping { Id = "test http" });
                 * for (int i = 0; i < 10; i++)
                 * {
                 *  mb1.NewMessage(new Ping { Id = "t1" })
                 *      .SetNonPersistentLocal()
                 *      .Publish();
                 * }*/
                DateTime dt = DateTime.Now;
                for (int j = 0; j < 100; j++)
                {
                    using (System.Transactions.TransactionScope ts = new System.Transactions.TransactionScope())
                    {
                        for (int i = 0; i < 100; i++)
                        {
                            //mb1.Send("sql://testdb2/MQueue2", new Ping { Id = (10 * j + i).ToString() });
                            ///send the message using fluent interface
                            mb1.NewMessage(new TestMessage1(j * 10 + i))
                            .SetDeliveryDate(DateTime.Now.AddSeconds(1))
                            .SetLabel("Test XX" + i)
                            .Publish();
                        }
                        if (j % 2 < 2)
                        {
                            ts.Complete();
                        }
                    }
                }
                log.Warn("Inserted 10K messages in {0}", DateTime.Now - dt);
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                log.Error("Error: {0}", ex);
                Console.ReadLine();
            }
        }
Beispiel #2
0
 public object Handle(TestMessage1 message)
 {
     Console.WriteLine("TestMessage1 {1} in saga {0}", Id, message.Id);
     return("nic");
 }