示例#1
0
        private static void StartQueueMonitoring()
        {
            var monitor = new QueueMonitor();

            monitor.AddComponents(MonitoredConsumers);
            monitor.Start();
        }
示例#2
0
        static void Main(string[] args)
        {
            var rabbitOptions = new RabbitOptions
            {
                HostName           = RabbitHostName,
                ExchangeName       = RabbitExchangeName,
                ExchangeAutoDelete = true,
                ExchangeDurable    = false
            };

            var reader    = new RabbitMessageReader(rabbitOptions);
            var converter = new RabbitMessageConverter();
            var source    = new ResourceValidatorSource(typeof(Program).Assembly, "Console.Rabbit.Schemas.{messageType}.json");
            var output    = new ConsoleValidationOutput();

            var monitor = new QueueMonitor(reader, converter, new MessageValidator(source), output);

            monitor.Start();

            var publisher = new Publisher(RabbitHostName, RabbitExchangeName);

            publisher.Start();

            System.Console.WriteLine("Monitoring {0} on {1}.  Press any key to stop.", rabbitOptions.ExchangeName, rabbitOptions.HostName);

            System.Console.ReadKey();
            System.Console.WriteLine("Stopping...");

            publisher.Stop();
            monitor.Stop();
        }
示例#3
0
        public Tests()
        {
            var source = new ResourceValidatorSource(GetType().Assembly, "Testing.PostTest.Xunit.Schemas.{messageType}.json");

            _queue  = new InMemoryMessageReader();
            _output = new InMemoryValidationOutput();

            _monitor = new QueueMonitor(_queue, new DirectMessageConverter(), new MessageValidator(source), _output);
            _monitor.Start();
        }
示例#4
0
        public AcceptanceTests()
        {
            _messages = new InMemoryMessageReader();
            _output = new InMemoryValidationOutput();
            _validators = new InMemoryValidationSource();

            var converter = new DirectMessageConverter();
            var validator = new MessageValidator(_validators);

            _queueMonitor = new QueueMonitor(_messages, converter, validator, _output);
            _queueMonitor.Start();
        }
示例#5
0
        protected override void OnStart(string[] args)
        {
            // replace these with your own adapters
            IMessageReader    reader    = new InMemoryMessageReader();
            IMessageConverter converter = new DirectMessageConverter();
            IValidatorSource  source    = new FileValidatorSource(Path.Combine(_baseDirectory, "validators"));

            var output = new SerilogValidationOutput();

            _monitor = new QueueMonitor(reader, converter, new MessageValidator(source), output);
            _monitor.Start();
        }
示例#6
0
            object AddQueueToGroup(Uri queue)
            {
                QueueMonitor monitor = null;

                lock (this.thisLock)
                {
                    monitor = new QueueMonitor(queue, this);
                    this.monitors.Add(monitor);
                    if (this.enabled)
                    {
                        monitor.Start();
                    }
                }

                return(monitor);
            }
示例#7
0
        static void Main(string[] args)
        {
            var d = new Dispatcher();
            var midgetHouse = new MidgetHouse(d);
            d.Subscribe<OrderPlaced>(midgetHouse);
            d.Subscribe<DodgyOrderPlaced>(midgetHouse);
            var manager = new Manager();
            var cashier = new Cashier(d);
            var ass = new AssMan(d);

            var cookDispatcher = new SmartDispatcher<CookFood>();
            var cookTtlGate = new TimeToLiveGate<CookFood>(cookDispatcher);
            var cookQueudHandler = new QueuedHandler<CookFood>(cookTtlGate, "cook ttl gate");
            var cookLimiter = new Limiter<CookFood>(cookQueudHandler);
            //var cookScrewsUp = new ScrewsUp<CookFood>(cookLimiter);

            var alarmClock = new AlarmClock(d);

            var messageMonitor = new MessageMonitor(d);
            var fmm = new FilePerOrderMonitor(d);

            d.Subscribe(alarmClock);
            d.Subscribe(cookLimiter);
            d.Subscribe(ass);
            d.Subscribe(cashier);
            d.Subscribe(manager);
            d.Subscribe<OrderPlaced>(messageMonitor);
            d.Subscribe<DodgyOrderPlaced>(messageMonitor);
            d.Subscribe<OrderPlaced>(fmm);
            d.Subscribe<DodgyOrderPlaced>(fmm);

            var cookQueudHandler1 = new QueuedHandler<CookFood>(new Cook(d, 10000), "c1");
            cookDispatcher.AddHandler(cookQueudHandler1);
            var cookQueudHandler2 = new QueuedHandler<CookFood>(new Cook(d, 5000), "c2");
            cookDispatcher.AddHandler(cookQueudHandler2);
            var cookQueudHandler3 = new QueuedHandler<CookFood>(new Cook(d, 100), "c3");
            cookDispatcher.AddHandler(cookQueudHandler3);

            var queueMonitor = new QueueMonitor(new IAmMonitored[] {cookQueudHandler1, cookQueudHandler2, cookQueudHandler3, cookQueudHandler,d.QueudHandler});

            //Cook cook = new Cook(ass);
            var waiter = new Waiter(d);

            cookQueudHandler1.Start();
            cookQueudHandler2.Start();
            cookQueudHandler3.Start();
            cookQueudHandler.Start();
            d.Start();
            alarmClock.Start();
            queueMonitor.Start();

            new Thread(TryPay).Start(cashier);

            Random r = new Random();
            for (int i = 0; i < 500; i++)
            {
                Guid orderNumber;
                if (r.Next()%2 == 0)
                {
                    orderNumber = waiter.PlaceDodgyOrder(new[] {Tuple.Create("Burger", 1)}, 15);

                }
                else
                {
                    orderNumber = waiter.PlaceOrder(new[] { Tuple.Create("Burger", 1) }, 15);
                }

                if(i > 2)Thread.Sleep(2000);

                orders.TryAdd(orderNumber, null);
            }
            //var orderNumber = waiter.PlaceOrder(new[] {Tuple.Create("Burger", 1)}, 15);
            //cashier.PayForOrder(orderNumber);
            Console.ReadLine();
        }
示例#8
0
            object AddQueueToGroup(Uri queue)
            {
                QueueMonitor monitor = null;
                lock (this.thisLock)
                {
                    monitor = new QueueMonitor(queue, this);
                    this.monitors.Add(monitor);
                    if (this.enabled)
                    {
                        monitor.Start();
                    }
                }

                return monitor;
            }