Пример #1
0
        public async Task Test1()
        {
            //Larva.MessageProcess.LoggerManager.SetLoggerProvider(new Log4NetLoggerProvider());
            var consumer = new CommandConsumer();

            consumer.Initialize(new ConsumerSettings
            {
                AmqpUri = new Uri("amqp://*****:*****@localhost/test")
            }, "MessageProcess_CommandTopic", 4, false, 1, new IInterceptor[] { new PerformanceCounterInterceptor() }, typeof(CommandTests).Assembly);
            consumer.Start();

            var commandBus = new CommandBus();

            commandBus.Initialize(new ProducerSettings
            {
                AmqpUri = new Uri("amqp://*****:*****@localhost/test")
            }, "MessageProcess_CommandTopic", 4, IPEndPoint.Parse("127.0.0.1:5000"));
            commandBus.Start();
            for (var i = 1; i <= 5; i++)
            {
                for (var j = 1; j <= 5; j++)
                {
                    await commandBus.SendAsync(new Command1($"Test{i}"));
                }
            }
            Thread.Sleep(1000);
            commandBus.Shutdown();

            Thread.Sleep(10000);
            consumer.Shutdown();
        }
Пример #2
0
        /// <summary>
        /// Start the host post preparing and registering handlers.
        /// </summary>
        protected virtual void Start()
        {
            StartBusRegistrar();

            var  configurationManager = DependencyResolver.Current.Resolve <IConfigurationManager>();
            bool setting;

            if (!configurationManager.TryGetSetting("Cqrs.Hosts.EnableEventReceiving", out setting))
            {
                setting = true;
            }
            if (setting)
            {
                EventBus.Start();
            }
            if (!configurationManager.TryGetSetting("Cqrs.Hosts.EnableCommandReceiving", out setting))
            {
                setting = true;
            }
            if (setting)
            {
                CommandBus.Start();
            }
        }