Esempio n. 1
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.");
        }
Esempio n. 2
0
        /// <summary>
        /// This method supports the AMFCore infrastructure and is not intended to be used directly from your code.
        /// </summary>
        public void Init()
        {
            _messageBroker = new MessageBroker(this);

            _serviceConfigSettings = ServiceConfigSettings.Load();
            foreach (ChannelSettings channelSettings in _serviceConfigSettings.ChannelsSettings)
            {
                Type type = ObjectFactory.Locate(channelSettings.Class);
                if (type != null)
                {
                    IEndpoint endpoint = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, channelSettings }) as IEndpoint;
                    if (endpoint != null)
                    {
                        _messageBroker.AddEndpoint(endpoint);
                    }
                }
            }
            foreach (FactorySettings factorySettings in _serviceConfigSettings.FactoriesSettings)
            {
                Type type = ObjectFactory.Locate(factorySettings.ClassId);
                if (type != null)
                {
                    IFlexFactory flexFactory = ObjectFactory.CreateInstance(type, new object[0]) as IFlexFactory;
                    if (flexFactory != null)
                    {
                        _messageBroker.AddFactory(factorySettings.Id, flexFactory);
                    }
                }
            }
            //Add the dotnet Factory
            _messageBroker.AddFactory("dotnet", new DotNetFactory());

            foreach (ServiceSettings serviceSettings in _serviceConfigSettings.ServiceSettings)
            {
                Type type = ObjectFactory.Locate(serviceSettings.Class);//current assembly only
                if (type != null)
                {
                    IService service = ObjectFactory.CreateInstance(type, new object[] { _messageBroker, serviceSettings }) as IService;
                    if (service != null)
                    {
                        _messageBroker.AddService(service);
                    }
                }
            }
        }
Esempio n. 3
0
        private static void InitializeENode()
        {
            int minWorker, minIOC;

            // Get the current settings.
            ThreadPool.GetMinThreads(out minWorker, out minIOC);
            // Change the minimum number of worker threads to four, but
            // keep the old setting for minimum asynchronous I/O
            // completion threads.
            ThreadPool.SetMinThreads(250, minIOC);

            ServiceConfigSettings.Initialize();
            DataConfigSettings.Initialize();

            var assemblies = new[]
            {
                Assembly.Load("Lottery.Infrastructure"),
                Assembly.Load("Lottery.Commands"),
                Assembly.Load("Lottery.Core"),
                Assembly.Load("Lottery.Denormalizers.Dapper"),
                Assembly.Load("Lottery.ProcessManagers"),
                Assembly.Load("Lottery.EventService")
            };

            _enodeConfiguration = Configuration
                                  .Create()
                                  .UseAutofac()
                                  .RegisterCommonComponents()
                                  .UseLog4Net()
                                  .UseJsonNet()
                                  .RegisterUnhandledExceptionHandler()
                                  .CreateENode()
                                  .RegisterENodeComponents()
                                  .RegisterBusinessComponents(assemblies)
                                  .UseSqlServerPublishedVersionStore()
                                  .UseEQueue()
                                  .UseRedisCache()
                                  .BuildContainer()
                                  .InitializeSqlServerPublishedVersionStore(DataConfigSettings.ENodeConnectionString)
                                  .InitializeBusinessAssemblies(assemblies);

            ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Program)).Info("Event service initialized.");
        }
Esempio n. 4
0
        protected static void Initialize()
        {
            if (_enodeConfiguration != null)
            {
                CleanupEnode();
            }

            ServiceConfigSettings.Initialize();
            DataConfigSettings.Initialize();

            InitializeENode();

            _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(TestBase));
            _logger.Info("ENode initialized.");

            _commandService = ObjectContainer.Resolve <ICommandService>();

            //ObjectContainer.Resolve<ILockService>().AddLockKey(typeof(LotteryData).Name);
        }
Esempio n. 5
0
        private void InitializeENode()
        {
            ServiceConfigSettings.Initialize();
            DataConfigSettings.Initialize();

            var assemblies = new[]
            {
                Assembly.Load("Lottery.Infrastructure"),
                Assembly.Load("Lottery.Commands"),
                Assembly.Load("Lottery.QueryServices"),
                Assembly.Load("Lottery.QueryServices.Dapper"),
                Assembly.Load("Lottery.AppService"),
                Assembly.Load("Lottery.WebApi")
            };

            Configuration
            .Create()
            .UseAutofac()
            .RegisterCommonComponents()
            .UseLog4Net()
            .UseJsonNet()
            .RegisterUnhandledExceptionHandler()
            .CreateENode()
            .RegisterENodeComponents()
            .RegisterBusinessComponents(assemblies)
            .UseEQueue()
            .UseRedisCache()
            .UseAutoMapper("Lottery.Dtos")
            .UseSqlServerPublishedVersionStore()
            .BuildContainer()
            .ClearCache()
            .InitEmailSeting()
            .InitializeBusinessAssemblies(assemblies)
            .InitLotteryEngine()
            .InitializeSqlServerPublishedVersionStore(DataConfigSettings.ENodeConnectionString)
            .StartEQueue()
            .Start();

            _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(GetType());
            _logger.Info("ENode initialized.");
        }
Esempio n. 6
0
        private static void InitializeEQueue()
        {
            _ecommonConfiguration = ECommonConfiguration
                                    .Create()
                                    .UseAutofac()
                                    .RegisterCommonComponents()
                                    .UseLog4Net()
                                    .UseJsonNet()
                                    .RegisterUnhandledExceptionHandler()
                                    .RegisterEQueueComponents()
                                    .BuildContainer();

            ServiceConfigSettings.Initialize();
            var setting = new NameServerSetting()
            {
                BindingAddress = ServiceConfigSettings.NameServerAddress
            };

            _nameServer = new NameServerController(setting);
            ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(Bootstrap).FullName).Info("NameServer initialized.");
        }
Esempio n. 7
0
        private static void InitializeENode()
        {
            ServiceConfigSettings.Initialize();
            DataConfigSettings.Initialize();

            var assemblies = new[]
            {
                Assembly.Load("Lottery.Infrastructure"),
                Assembly.Load("Lottery.Commands"),
                Assembly.Load("Lottery.Core"),
                Assembly.Load("Lottery.Denormalizers.Dapper"),
                Assembly.Load("Lottery.CommandHandlers"),
                Assembly.Load("Lottery.CommandService"),
            };

            // var setting = new ConfigurationSetting(DataConfigSettings.ENodeConnectionString);

            _enodeConfiguration = Configuration
                                  .Create()
                                  .UseAutofac()
                                  .RegisterCommonComponents()
                                  .UseLog4Net()
                                  .UseJsonNet()
                                  .RegisterUnhandledExceptionHandler()
                                  .CreateENode()
                                  .RegisterENodeComponents()
                                  .RegisterBusinessComponents(assemblies)
                                  .UseSqlServerEventStore()
                                  .UseSqlServerLockService()
                                  .UseEQueue()
                                  .UseRedisCache()
                                  .BuildContainer()
                                  .InitializeBusinessAssemblies(assemblies)
                                  .InitializeSqlServerEventStore(DataConfigSettings.ENodeConnectionString)
                                  .InitializeSqlServerLockService(DataConfigSettings.ENodeConnectionString)
                                  .Start();
        }
Esempio n. 8
0
 public static void InitializeFramework()
 {
     ServiceConfigSettings.Initialize();
     DataConfigSettings.Initialize();
     InitializeENodeFramework();
 }