Exemplo n.º 1
0
        public static void Main()
        {
            using (IUnityContainer container = new UnityContainer())
            {
                container.RegisterInstance(typeof(ISpy), new NullSpy());

                using (ProcessorConfiguration config = new ProcessorConfiguration())
                {
                    config.DefaultHandlerLifetime = HandlerLifetime.Transient;

                    config.RegisterCommandHandler<TestCommand>(async command =>
                    {
                        await Task.FromResult(0);
                    });

                    config.RegisterCommandHandler<TestCommand2>(async command =>
                    {
                        await Task.FromResult(0);
                    });

                    ////  config.RegisterContainer(container);
                    //// config.Services.Replace(typeof(ICommandValidator), new NullValidator());
                    ////  config.EnableDefaultTracing();

                    ////  PerformanceTracer traceWriter = new PerformanceTracer();

                    ////config.Services.Replace(typeof(ITraceWriter), traceWriter);
                    ////    traceWorker.MinimumLevel = Tracing.TraceLevel.DefaultCommandValidator;
                    ////config.Filters.Add(new CustomExceptionFilterAttribute());

                    ////   long initialMemory = GC.GetTotalMemory(false);

                    ////    config.EnableGlobalExceptionHandler();

                    const int MaxIterations = 100000;
                    config.EnableRedisMessageQueuing("localhost");
                    using (MessageProcessor processor = new MessageProcessor(config))
                    {
                        processor.ProcessAsync(new TestCommand());
                        SingleProcessing(processor);
                        ParallelProcessing(MaxIterations, processor);
                        ////   SequentialTaskProcessing(maxIterations, processor);
                        ////   SequentialTaskProcessingV2(maxIterations, processor);
                        ////  SequentialTaskProcessingV3(maxIterations, processor);

                        RunCommandBroker(config.CommandBroker);
                    }
                }
            ////    Console.ReadLine();
            }
        }