Exemplo n.º 1
0
        static void InitializeENodeFramework()
        {
            var assemblies = new[]
            {
                Assembly.Load("NoteSample.Domain"),
                Assembly.Load("NoteSample.Commands"),
                Assembly.Load("NoteSample.CommandHandlers"),
                Assembly.GetExecutingAssembly()
            };
            var loggerFactory = new SerilogLoggerFactory()
                                .AddFileLogger("ECommon", "logs\\ecommon")
                                .AddFileLogger("EQueue", "logs\\equeue")
                                .AddFileLogger("ENode", "logs\\enode");

            _configuration = ECommonConfiguration
                             .Create()
                             .UseAutofac()
                             .RegisterCommonComponents()
                             .UseSerilog(loggerFactory)
                             .UseJsonNet()
                             .RegisterUnhandledExceptionHandler()
                             .CreateENode()
                             .RegisterENodeComponents()
                             .RegisterBusinessComponents(assemblies)
                             .BuildContainer()
                             .InitializeBusinessAssemblies(assemblies);
            _eventService = ObjectContainer.Resolve <IEventCommittingService>();

            _logger           = ObjectContainer.Resolve <ILoggerFactory>().Create("main");
            _repository       = ObjectContainer.Resolve <IRepository>();
            _commandProcessor = ObjectContainer.Resolve <ICommandProcessor>();

            Console.WriteLine("ENode started...");
        }
Exemplo n.º 2
0
        private void InitializeENode(
            bool useMockEventStore                  = false,
            bool useMockPublishedVersionStore       = false,
            bool useMockDomainEventPublisher        = false,
            bool useMockApplicationMessagePublisher = false,
            bool useMockDomainExceptionPublisher    = false)
        {
            var connectionString = ConfigurationManager.AppSettings["connectionString"];
            var assemblies       = new[]
            {
                Assembly.GetExecutingAssembly()
            };

            if (_serilogLoggerFactory == null)
            {
                _serilogLoggerFactory = new SerilogLoggerFactory(defaultLoggerFileName: "logs\\default")
                                        .AddFileLogger("ECommon", "logs\\ecommon")
                                        .AddFileLogger("EQueue", "logs\\equeue")
                                        .AddFileLogger("ENode", "logs\\enode");
            }
            _enodeConfiguration = ECommonConfiguration
                                  .Create()
                                  .UseAutofac()
                                  .RegisterCommonComponents()
                                  .UseSerilog(_serilogLoggerFactory)
                                  .UseJsonNet()
                                  .RegisterUnhandledExceptionHandler()
                                  .CreateENode()
                                  .RegisterENodeComponents()
                                  .UseEventStore(useMockEventStore)
                                  .UsePublishedVersionStore(useMockPublishedVersionStore)
                                  .RegisterBusinessComponents(assemblies)
                                  .InitializeEQueue()
                                  .UseEQueue(useMockDomainEventPublisher, useMockApplicationMessagePublisher, useMockDomainExceptionPublisher)
                                  .BuildContainer();

            if (!useMockEventStore)
            {
                _enodeConfiguration.InitializeSqlServerEventStore(connectionString);
            }
            if (!useMockPublishedVersionStore)
            {
                _enodeConfiguration.InitializeSqlServerPublishedVersionStore(connectionString);
            }

            _enodeConfiguration
            .InitializeBusinessAssemblies(assemblies)
            .StartEQueue()
            .Start();

            _commandService              = ObjectContainer.Resolve <ICommandService>();
            _memoryCache                 = ObjectContainer.Resolve <IMemoryCache>();
            _eventStore                  = ObjectContainer.Resolve <IEventStore>();
            _publishedVersionStore       = ObjectContainer.Resolve <IPublishedVersionStore>();
            _domainEventPublisher        = ObjectContainer.Resolve <IMessagePublisher <DomainEventStreamMessage> >();
            _applicationMessagePublisher = ObjectContainer.Resolve <IMessagePublisher <IApplicationMessage> >();
            _domainExceptionPublisher    = ObjectContainer.Resolve <IMessagePublisher <IDomainException> >();
            _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(BaseTest));
            _logger.Info("----ENode initialized.");
        }
        private void ConfigureContainer(ContainerBuilder builder)
        {
            BuildConfiguration();

            var brokerAddresses = Root["Kafka:BrokerAddresses"];

            _bussinessAssemblies = new[]
            {
                Assembly.GetExecutingAssembly()
            };

            _enodeConfiguration = ECommonConfiguration
                                  .Create()
                                  .UseAutofac(builder)
                                  .RegisterCommonComponents()
                                  .UseLog4Net()
                                  .UseJsonNet()
                                  .RegisterUnhandledExceptionHandler()
                                  .CreateENode(new ConfigurationSetting()
            {
                ProcessTryToRefreshAggregateIntervalMilliseconds = 1000
            })
                                  .RegisterENodeComponents()
                                  .UseEventStore(false)
                                  .UsePublishedVersionStore(false)
                                  .UseAggregateSnapshot(false)
                                  .RegisterBusinessComponents(_bussinessAssemblies)
                                  .InitializeKafka(GetIPEndPointFromAddresses(brokerAddresses))
                                  .UseKafka(false, false, false);
        }
Exemplo n.º 4
0
        static void InitializeENodeFramework()
        {
            var setting = new ConfigurationSetting
            {
                SqlDefaultConnectionString = ConfigurationManager.AppSettings["connectionString"]
            };
            var assemblies = new[]
            {
                Assembly.Load("NoteSample.Domain"),
                Assembly.Load("NoteSample.CommandHandlers"),
                Assembly.Load("NoteSample.Commands"),
                Assembly.GetExecutingAssembly()
            };

            _configuration = ECommonConfiguration
                             .Create()
                             .UseAutofac()
                             .RegisterCommonComponents()
                             .UseLog4Net()
                             .UseJsonNet()
                             .RegisterUnhandledExceptionHandler()
                             .CreateENode(setting)
                             .RegisterENodeComponents()
                             .UseSqlServerEventStore()
                             .RegisterBusinessComponents(assemblies)
                             .InitializeBusinessAssemblies(assemblies)
                             .UseEQueue()
                             .StartEQueue();

            _commandService = ObjectContainer.Resolve <ICommandService>();
            _memoryCache    = ObjectContainer.Resolve <IMemoryCache>();
        }
Exemplo n.º 5
0
        static void InitializeENodeFramework()
        {
            var assemblies = new[]
            {
                Assembly.Load("NoteSample.Domain"),
                Assembly.Load("NoteSample.Commands"),
                Assembly.Load("NoteSample.CommandHandlers"),
                Assembly.GetExecutingAssembly()
            };
            var setting = new ConfigurationSetting(_connectionString);

            setting.DefaultDBConfigurationSetting.EventTableCount = _eventTableCount;

            _configuration = ECommonConfiguration
                             .Create()
                             .UseAutofac()
                             .RegisterCommonComponents()
                             .UseLog4Net()
                             .UseJsonNet()
                             .RegisterUnhandledExceptionHandler()
                             .CreateENode(setting)
                             .RegisterENodeComponents()
                             .UseSqlServerEventStore()
                             .RegisterBusinessComponents(assemblies)
                             .InitializeBusinessAssemblies(assemblies);
            _eventService = ObjectContainer.Resolve <IEventService>();

            _logger           = ObjectContainer.Resolve <ILoggerFactory>().Create("main");
            _repository       = ObjectContainer.Resolve <IRepository>();
            _commandProcessor = ObjectContainer.Resolve <ICommandProcessor>();

            Console.WriteLine("ENode started...");
        }
Exemplo n.º 6
0
        static void InitializeEQueue()
        {
            ECommonConfiguration
            .Create()
            .UseAutofac()
            .RegisterCommonComponents()
            .UseLog4Net()
            .UseJsonNet()
            .RegisterUnhandledExceptionHandler()
            .RegisterEQueueComponents();

            var address       = ConfigurationManager.AppSettings["BrokerAddress"];
            var brokerAddress = string.IsNullOrEmpty(address) ? SocketUtils.GetLocalIPV4() : IPAddress.Parse(address);
            var clientCount   = int.Parse(ConfigurationManager.AppSettings["ClientCount"]);
            var setting       = new ConsumerSetting
            {
                ConsumeFromWhere   = ConsumeFromWhere.FirstOffset,
                MessageHandleMode  = MessageHandleMode.Parallel,
                BrokerAddress      = new IPEndPoint(brokerAddress, 5001),
                BrokerAdminAddress = new IPEndPoint(brokerAddress, 5002)
            };
            var messageHandler = new MessageHandler();

            for (var i = 1; i <= clientCount; i++)
            {
                new Consumer(ConfigurationManager.AppSettings["ConsumerGroup"], setting)
                .Subscribe(ConfigurationManager.AppSettings["Topic"])
                .SetMessageHandler(messageHandler)
                .Start();
            }
        }
Exemplo n.º 7
0
        private static void InitializeEQueue()
        {
            _ecommonConfiguration = ECommonConfiguration
                                    .Create()
                                    .UseAutofac()
                                    .RegisterCommonComponents()
                                    .UseLog4Net()
                                    .UseJsonNet()
                                    .RegisterUnhandledExceptionHandler()
                                    .RegisterEQueueComponents()
                                    .BuildContainer();
            ConfigSettings.Initialize();
            var storePath           = ConfigurationManager.AppSettings["equeueStorePath"];
            var nameServerEndpoint  = new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort);
            var nameServerEndpoints = new List <IPEndPoint> {
                nameServerEndpoint
            };
            var brokerSetting = new BrokerSetting(false, storePath)
            {
                NameServerList = nameServerEndpoints
            };

            brokerSetting.BrokerInfo.ProducerAddress = new IPEndPoint(IPAddress.Loopback, ConfigSettings.BrokerProducerPort).ToAddress();
            brokerSetting.BrokerInfo.ConsumerAddress = new IPEndPoint(IPAddress.Loopback, ConfigSettings.BrokerConsumerPort).ToAddress();
            brokerSetting.BrokerInfo.AdminAddress    = new IPEndPoint(IPAddress.Loopback, ConfigSettings.BrokerAdminPort).ToAddress();
            _broker = BrokerController.Create(brokerSetting);
            ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Bootstrap).FullName).Info("Broker initialized.");
        }
Exemplo n.º 8
0
        private static void InitializeEQueue()
        {
            _ecommonConfiguration = ECommonConfiguration
                                    .Create()
                                    .UseAutofac()
                                    .RegisterCommonComponents()
                                    .UseLog4Net()
                                    .UseJsonNet()
                                    .RegisterUnhandledExceptionHandler()
                                    .RegisterEQueueComponents()
                                    .BuildContainer();

            ServiceConfigSettings.Initialize();

            var brokerSetting = new BrokerSetting(false, ServiceConfigSettings.EqueueStorePath)
            {
                NameServerList = ServiceConfigSettings.NameServerEndpoints
            };

            brokerSetting.BrokerInfo.ProducerAddress = ServiceConfigSettings.BrokerProducerServiceAddress;
            brokerSetting.BrokerInfo.ConsumerAddress = ServiceConfigSettings.BrokerConsumerServiceAddress;
            brokerSetting.BrokerInfo.AdminAddress    = ServiceConfigSettings.BrokerAdminServiceAddress;
            brokerSetting.BrokerInfo.BrokerName      = ServiceConfigSettings.BrokerName;
            brokerSetting.BrokerInfo.GroupName       = ServiceConfigSettings.BrokerGroup;

            _broker = BrokerController.Create(brokerSetting);
            ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Program).FullName).Info("Broker initialized.");
        }
Exemplo n.º 9
0
        static void InitializeECommon()
        {
            _message      = new byte[int.Parse(ConfigurationManager.AppSettings["MessageSize"])];
            _mode         = ConfigurationManager.AppSettings["Mode"];
            _messageCount = int.Parse(ConfigurationManager.AppSettings["MessageCount"]);

            var logContextText = "mode: " + _mode;

            ECommonConfiguration
            .Create()
            .UseAutofac()
            .RegisterCommonComponents()
            .UseLog4Net()
            .RegisterUnhandledExceptionHandler()
            .BuildContainer();

            _logger             = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Program).Name);
            _performanceService = ObjectContainer.Resolve <IPerformanceService>();
            var setting = new PerformanceServiceSetting
            {
                AutoLogging            = false,
                StatIntervalSeconds    = 1,
                PerformanceInfoHandler = x =>
                {
                    _logger.InfoFormat("{0}, {1}, totalCount: {2}, throughput: {3}, averageThrughput: {4}, rt: {5:F3}ms, averageRT: {6:F3}ms", _performanceService.Name, logContextText, x.TotalCount, x.Throughput, x.AverageThroughput, x.RT, x.AverageRT);
                }
            };

            _performanceService.Initialize(_performanceKey, setting);
            _performanceService.Start();
        }
Exemplo n.º 10
0
        private static void InitializeEQueue()
        {
            var loggerFactory = new SerilogLoggerFactory()
                                .AddFileLogger("ECommon", "logs\\ecommon")
                                .AddFileLogger("EQueue", "logs\\equeue")
                                .AddFileLogger("ENode", "logs\\enode");

            _ecommonConfiguration = ECommonConfiguration
                                    .Create()
                                    .UseAutofac()
                                    .RegisterCommonComponents()
                                    .UseSerilog(loggerFactory)
                                    .UseJsonNet()
                                    .RegisterUnhandledExceptionHandler()
                                    .RegisterEQueueComponents()
                                    .BuildContainer();
            ConfigSettings.Initialize();
            var setting = new NameServerSetting()
            {
                BindingAddress = new IPEndPoint(IPAddress.Loopback, ConfigSettings.NameServerPort)
            };

            _nameServer = new NameServerController(setting);
            ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Bootstrap).FullName).Info("NameServer initialized.");
        }
Exemplo n.º 11
0
        public MongoDbPublishedVersionStore_Tests()
        {
            var assemblies = new[] { Assembly.GetExecutingAssembly() };

            var enode = ECommonConfiguration.Create()
                        .UseAutofac()
                        .RegisterCommonComponents()
                        .UseLog4Net()
                        .UseJsonNet()
                        .CreateENode(new ConfigurationSetting())
                        .RegisterBusinessComponents(assemblies)
                        .RegisterENodeComponents()
                        .UseMongoDbPublishedVersionStore()
                        .UseMongoDbAggregateSnapshotter();

            enode.GetCommonConfiguration()
            .BuildContainer();

            enode.InitializeBusinessAssemblies(assemblies)
            .InitializeMongoDbPublishedVersionStore(_mongoDbConfiguration)
            .InitializeMongoDbAggregateSnapshotter(_mongoDbConfiguration);

            _store            = ObjectContainer.Resolve <IPublishedVersionStore>();
            _typeNameProvider = ObjectContainer.Resolve <ITypeNameProvider>();
        }
Exemplo n.º 12
0
        static void InitializeENodeFramework()
        {
            var setting = new ConfigurationSetting
            {
                SqlDefaultConnectionString = ConfigurationManager.AppSettings["connectionString"],
                EnableGroupCommitEvent     = bool.Parse(ConfigurationManager.AppSettings["batchCommit"]),
                GroupCommitMaxSize         = int.Parse(ConfigurationManager.AppSettings["batchSize"])
            };
            var assemblies = new[]
            {
                Assembly.Load("NoteSample.Domain"),
                Assembly.Load("NoteSample.Commands"),
                Assembly.Load("NoteSample.CommandHandlers"),
                Assembly.GetExecutingAssembly()
            };

            _configuration = ECommonConfiguration
                             .Create()
                             .UseAutofac()
                             .RegisterCommonComponents()
                             .UseLog4Net()
                             .UseJsonNet()
                             .RegisterUnhandledExceptionHandler()
                             .CreateENode(setting)
                             .RegisterENodeComponents()
                             .UseSqlServerEventStore()
                             .RegisterBusinessComponents(assemblies)
                             .InitializeBusinessAssemblies(assemblies);

            Console.WriteLine("ENode started...");
        }
Exemplo n.º 13
0
        static void InitializeEQueue()
        {
            ECommonConfiguration
            .Create()
            .UseAutofac()
            .RegisterCommonComponents()
            .UseLog4Net()
            .UseJsonNet()
            .RegisterUnhandledExceptionHandler()
            .RegisterEQueueComponents()
            .SetDefault <IQueueSelector, QueueAverageSelector>();

            _logger             = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Program).Name);
            _performanceService = ObjectContainer.Resolve <IPerformanceService>();
            _mode = ConfigurationManager.AppSettings["Mode"];
            var logContextText = "mode: " + _mode;
            var setting        = new PerformanceServiceSetting
            {
                AutoLogging            = false,
                StatIntervalSeconds    = 1,
                PerformanceInfoHandler = x =>
                {
                    _logger.InfoFormat("{0}, {1}, totalCount: {2}, throughput: {3}, averageThrughput: {4}, rt: {5:F3}ms, averageRT: {6:F3}ms", _performanceService.Name, logContextText, x.TotalCount, x.Throughput, x.AverageThroughput, x.RT, x.AverageRT);
                }
            };

            _performanceService.Initialize("SendMessage", setting).Start();
        }
Exemplo n.º 14
0
 static void InitializeEQueue()
 {
     ECommonConfiguration
     .Create()
     .UseAutofac()
     .RegisterCommonComponents()
     .UseLog4Net()
     .UseJsonNet()
     .RegisterEQueueComponents();
 }
Exemplo n.º 15
0
 private static void InitializeECommon()
 {
     _configuration = ECommonConfiguration
                      .Create()
                      .UseAutofac()
                      .RegisterCommonComponents()
                      .UseLog4Net()
                      .UseJsonNet()
                      .RegisterUnhandledExceptionHandler();
 }
Exemplo n.º 16
0
        private static async Task Main(string[] args)
        {
            var assemblies = new[] { Assembly.GetExecutingAssembly() };

            var enode = ECommonConfiguration.Create()
                        .UseAutofac()
                        .RegisterCommonComponents()
                        .UseLog4Net()
                        .UseJsonNet()
                        .CreateENode(new ConfigurationSetting())
                        .RegisterBusinessComponents(assemblies)
                        .RegisterENodeComponents()
                        .UseRedisLockService();

            enode.GetCommonConfiguration()
            .BuildContainer();

            enode.InitializeBusinessAssemblies(assemblies)
            .InitializeRedisLockService(_redisOptions);

            _lockService = ObjectContainer.Resolve <ILockService>();

            var listDics = new List <(int index, Dictionary <int, int> dic)>();

            for (int i = 0; i < 10; i++)
            {
                listDics.Add((i, new Dictionary <int, int>()));
            }
            var tasks     = new List <Task>();
            var stopWatch = new Stopwatch();

            var lockKey = Guid.NewGuid().ToString();

            stopWatch.Start();
            for (int i = 0; i < 1000; i++)
            {
                foreach (var item in listDics)
                {
                    tasks.Add(_lockService.ExecuteInLockAsync($"{lockKey}-{item.index}", async() =>
                    {
                        await Task.Delay(10);
                        item.dic.Add(item.dic.Count, Thread.CurrentThread.GetHashCode());
                        Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss,fff")} {Thread.CurrentThread.GetHashCode()} {item.dic.Count} complete");
                    }));
                }
            }
            await Task.WhenAll(tasks);

            stopWatch.Stop();

            Console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss,fff")} all complete use time[{stopWatch.ElapsedMilliseconds}]");
            await Task.Delay(60000);

            Console.ReadKey();
        }
Exemplo n.º 17
0
 static void InitializeEQueue()
 {
     var configuration = ECommonConfiguration
                         .Create()
                         .UseAutofac()
                         .RegisterCommonComponents()
                         .UseLog4Net()
                         .UseJsonNet()
                         .RegisterUnhandledExceptionHandler()
                         .RegisterEQueueComponents()
                         .BuildContainer();
 }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            ECommonConfiguration
            .Create()
            .UseAutofac()
            .RegisterCommonComponents()
            .UseLog4Net()
            .RegisterUnhandledExceptionHandler();

            new SocketRemotingServer().RegisterRequestHandler(100, new RequestHandler()).Start();
            Console.ReadLine();
        }
Exemplo n.º 19
0
        static void InitializeECommon()
        {
            ECommonConfiguration
            .Create()
            .UseAutofac()
            .RegisterCommonComponents()
            .UseLog4Net()
            .RegisterUnhandledExceptionHandler();

            _logger          = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Program).Name);
            _scheduleService = ObjectContainer.Resolve <IScheduleService>();
        }
Exemplo n.º 20
0
 private static void InitializeECommon()
 {
     _ecommonConfiguration = ECommonConfiguration
                             .Create()
                             .UseAutofac()
                             .RegisterCommonComponents()
                             .UseLog4Net()
                             .UseJsonNet()
                             .RegisterUnhandledExceptionHandler();
     _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(PersonTestBase).Name);
     _logger.Info("ECommon initialized.");
 }
Exemplo n.º 21
0
 /// <summary>
 /// 初始化ECommon
 /// </summary>
 private static void InitializeECommon()
 {
     _configuration = ECommonConfiguration
                      .Create()
                      .UseAutofac()
                      .RegisterCommonComponents()
                      .UseLog4Net()
                      .UseJsonNet()
                      .RegisterUnhandledExceptionHandler();
     _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Bootstrap).FullName);
     _logger.Info("ECommon 初始化成功.");
 }
Exemplo n.º 22
0
 /// <summary>
 /// 初始化 ECommon
 /// </summary>
 private static void InitializeECommon()
 {
     _ecommonConfiguration = ECommonConfiguration
                             .Create()                   //创建一个ECommonConfiguration类的实例
                             .UseAutofac()               //使用的是Autofac容器
                             .RegisterCommonComponents() //把一些默认的组件注入到容器中
                             .UseLog4Net()
                             .UseJsonNet()
                             .RegisterUnhandledExceptionHandler();//告诉框架要捕获未处理的异常,这样框架在发现有未处理的异常时,会尝试记录错误日志
     _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Bootstrap).FullName);
     _logger.Info("ECommon 初始化成功.");
 }
Exemplo n.º 23
0
 private static void InitializeEqueue()
 {
     ECommonConfiguration
     .Create()
     .UseAutofac()
     .RegisterCommonComponents()
     .UseLog4Net()
     .UseJsonNet()
     .RegisterUnhandledExceptionHandler()
     .RegisterEQueueComponents()
     .UseDeleteMessageByCountStrategy(10);
 }
Exemplo n.º 24
0
 private static void InitializeECommon()
 {
     _ecommonConfiguration = ECommonConfiguration
         .Create()
         .UseAutofac()
         .RegisterCommonComponents()
         .UseLog4Net()
         .UseJsonNet()
         .RegisterUnhandledExceptionHandler();
     _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(typeof(Bootstrap).FullName);
     _logger.Info("ECommon initialized.");
 }
Exemplo n.º 25
0
        private static void InitializeENode(
            bool useMockEventStore                    = false,
            bool useMockPublishedVersionStore         = false,
            bool useMockDomainEventPublisher          = false,
            bool useMockApplicationMessagePublisher   = false,
            bool useMockPublishableExceptionPublisher = false)
        {
            var setting    = new ConfigurationSetting(ConfigurationManager.AppSettings["connectionString"]);
            var assemblies = new[]
            {
                Assembly.GetExecutingAssembly()
            };

            _enodeConfiguration = ECommonConfiguration
                                  .Create()
                                  .UseAutofac()
                                  .RegisterCommonComponents()
                                  .UseLog4Net()
                                  .UseJsonNet()
                                  .RegisterUnhandledExceptionHandler()
                                  .CreateENode(setting)
                                  .RegisterENodeComponents()
                                  .UseEventStore(useMockEventStore)
                                  .UsePublishedVersionStore(useMockPublishedVersionStore)
                                  .RegisterBusinessComponents(assemblies)
                                  .UseEQueue(useMockDomainEventPublisher, useMockApplicationMessagePublisher, useMockPublishableExceptionPublisher)
                                  .BuildContainer();

            if (!useMockEventStore)
            {
                _enodeConfiguration.InitializeSqlServerEventStore();
            }
            if (!useMockPublishedVersionStore)
            {
                _enodeConfiguration.InitializeSqlServerPublishedVersionStore();
            }

            _enodeConfiguration
            .InitializeBusinessAssemblies(assemblies)
            .StartEQueue()
            .Start();

            _commandService                = ObjectContainer.Resolve <ICommandService>();
            _memoryCache                   = ObjectContainer.Resolve <IMemoryCache>();
            _eventStore                    = ObjectContainer.Resolve <IEventStore>();
            _publishedVersionStore         = ObjectContainer.Resolve <IPublishedVersionStore>();
            _domainEventPublisher          = ObjectContainer.Resolve <IMessagePublisher <DomainEventStreamMessage> >();
            _applicationMessagePublisher   = ObjectContainer.Resolve <IMessagePublisher <IApplicationMessage> >();
            _publishableExceptionPublisher = ObjectContainer.Resolve <IMessagePublisher <IPublishableException> >();
            _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(BaseTest));
            _logger.Info("ENode initialized.");
        }
Exemplo n.º 26
0
 private static void InitializeEqueue()
 {
     ECommonConfiguration.Create()
     .UseAutofac()
     .RegisterCommonComponents()
     .UseLog4Net()
     .UseJsonNet()
     .RegisterUnhandledExceptionHandler()
     .RegisterEQueueComponents()
     .UseDeleteMessageByCountStrategy(10)
     .SetDefault <IQueueSelector, QueueAverageSelector>()
     .BuildContainer();
 }
Exemplo n.º 27
0
 static void InitializeEQueue()
 {
     var configuration = ECommonConfiguration
                         .Create()
                         .UseAutofac()
                         .RegisterCommonComponents()
                         .UseSerilog()
                         .UseJsonNet()
                         .RegisterUnhandledExceptionHandler()
                         .RegisterEQueueComponents()
                         .UseDeleteMessageByCountStrategy(5)
                         .BuildContainer();
 }
Exemplo n.º 28
0
        static void Main(string[] args)
        {
            ECommonConfiguration
            .Create()
            .UseAutofac()
            .RegisterCommonComponents()
            .UseLog4Net()
            .RegisterUnhandledExceptionHandler();

            _logger         = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Program).Name);
            _remotingServer = new SocketRemotingServer().Start();
            PushTestMessageToAllClients();
            Console.ReadLine();
        }
Exemplo n.º 29
0
        public NettyTestBase()
        {
            var assemblies = new[] { Assembly.GetExecutingAssembly() };

            var enode = ECommonConfiguration.Create()
                        .UseAutofac()
                        .RegisterCommonComponents()
                        .UseLog4Net()
                        .UseJsonNet()
                        .CreateENode(new ConfigurationSetting())
                        .RegisterBusinessComponents(assemblies)
                        .RegisterENodeComponents();

            enode.GetCommonConfiguration()
            .BuildContainer();
        }
Exemplo n.º 30
0
        static void InitializeEQueue()
        {
            ECommonConfiguration
            .Create()
            .UseAutofac()
            .RegisterCommonComponents()
            .UseLog4Net()
            .UseJsonNet()
            .RegisterUnhandledExceptionHandler()
            .RegisterEQueueComponents()
            .SetDefault <IQueueSelector, QueueAverageSelector>();

            _logger             = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Program).Name);
            _scheduleService    = ObjectContainer.Resolve <IScheduleService>();
            _rtStatisticService = ObjectContainer.Resolve <IRTStatisticService>();
        }
Exemplo n.º 31
0
        static void InitializeECommon()
        {
            ECommonConfiguration
            .Create()
            .UseAutofac()
            .RegisterCommonComponents()
            .UseLog4Net()
            .RegisterUnhandledExceptionHandler();

            _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Program).Name);
            var serverIP      = ConfigurationManager.AppSettings["ServerAddress"];
            var serverAddress = string.IsNullOrEmpty(serverIP) ? SocketUtils.GetLocalIPV4() : IPAddress.Parse(serverIP);

            _client = new SocketRemotingClient(new IPEndPoint(serverAddress, 5000)).Start();
            _client.RegisterRemotingServerMessageHandler(100, new RemotingServerMessageHandler());
        }