Exemple #1
0
        static void Test1()
        {
            var client = new MQClient
            {
                Servers = new[] { "tcp://127.0.0.1:6789" },
                Log     = XTrace.Log,

                Topic = "测试主题",
            };

            var msgid = client.Public("发布测试").Result;

            XTrace.WriteLine("msgid={0}", msgid);

            while (true)
            {
                for (var i = 0; i < 10; i++)
                {
                    Thread.Sleep(200);

                    msgid = client.Public(Rand.NextString(16)).Result;
                    XTrace.WriteLine("msgid={0}", msgid);
                }

                var key = Console.ReadKey(true);
                if (key.Key != ConsoleKey.C)
                {
                    break;
                }
            }
        }
Exemple #2
0
        static async void Test1()
        {
            var client = new MQClient
            {
                Servers = new[] { "tcp://127.0.0.1:6789" },
                Log     = XTrace.Log,

                Topic = "Test",
            };

            var msgid = await client.Public("发布测试");

            XTrace.WriteLine("msgid={0}", msgid);

            for (var i = 0; i < 10; i++)
            {
                Thread.Sleep(200);

                msgid = await client.Public(Rand.NextString(16));

                XTrace.WriteLine("msgid={0}", msgid);
            }

            var msgs = await client.Pull(0, 32, 15_000);

            Console.WriteLine(msgs);
        }
Exemple #3
0
        public void Run()
        {
            stopwatch.Start();
            using (MQClient = new MQClient())
            {
                UnitOfWork uow = uowGen.GenerateUOWFirstCalc();
                while (uow != null)
                {
                    MQClient.Call(uow);
                    uow = uowGen.GenerateUOWFirstCalc();
                }

                MQClient.WatiForNotification();

                uow = uowGen.GenerateUOWSecondCalc();
                while (uow != null)
                {
                    MQClient.Call(uow);
                    uow = uowGen.GenerateUOWSecondCalc();
                }

                MQClient.WatiForNotification();
            }
            stopwatch.Stop();
            time = stopwatch.ElapsedMilliseconds;
            AddTimeToLog();
        }
Exemple #4
0
 private void DeinitMQClient()
 {
     if (MQClient != null)
     {
         MQClient.Unsubscribe(AccountsChannel);
         MQClient.Dispose();
         MQClient = null;
     }
 }
Exemple #5
0
        static void Main(string[] args)
        {
            MatrixAccessor inputContainer;

            try
            {
                inputContainer = new MatrixAccessor();
                using (MQClient worker = new MQClient(inputContainer))
                {
                    worker.Run();
                }
            }
            catch (Exception ex)
            {
                System.Console.WriteLine("Worker could not load input matrixes");
            }
        }
Exemple #6
0
        static void Main(string[] args)
        {
            //DependencyFactory factory = new DependencyFactory();

            //var serilaize = factory.Container
            WorkerTimeLogger logger = new WorkerTimeLogger();
            MatrixAccessor   inputContainer;

            inputContainer = new MatrixAccessor();
            using (MQClient client = new MQClient(inputContainer, logger))
            {
                client.Run();
            }
            string path = Environment.CurrentDirectory + @"\log.txt";

            using (StreamWriter sw = new StreamWriter(path))
            {
                logger.SaveLog(sw);
            }
        }
Exemple #7
0
        static void Test2()
        {
            var client = new MQClient
            {
                Servers = new[] { "tcp://127.0.0.1:6789" },
                Log     = XTrace.Log,

                Topic = "测试主题",
            };

            client.OnConsume = msgs =>
            {
                foreach (var item in msgs)
                {
                    XTrace.WriteLine("消费到 {0}", item);
                }

                return(msgs.Max(e => e.ID));
            };
            client.StartConsume();
        }