public static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            //var sf = BuildSessionFactory();
            var container = new Container();

            var cfg = new CronusSettings(container)
                .UseContractsFromAssemblies(new Assembly[] { Assembly.GetAssembly(typeof(RegisterAccount)), Assembly.GetAssembly(typeof(CreateUser)) })
                .UseProjectionConsumer(consumer => consumer
                .SetNumberOfConsumerThreads(5)
                    .WithDefaultPublishersWithRabbitMq()
                    .UseRabbitMqTransport()
                    .UseProjections(h => h
                        //.UseUnitOfWork(new UnitOfWorkFactory() { CreateBatchUnitOfWork = () => new BatchScope(sf) })
                        .RegisterAllHandlersInAssembly(Assembly.GetAssembly(typeof(UserProjection)))));
            //{
            //                return FastActivator.CreateInstance(type)
            //                    .AssignPropertySafely<IHaveNhibernateSession>(x => x.Session = context.BatchContext.Get<Lazy<ISession>>().Value);
            //            })));

            (cfg as ISettingsBuilder).Build();
            host = container.Resolve<CronusHost>();
            host.Start();

            Console.WriteLine("Projections started");
            Console.ReadLine();
            host.Stop();
        }
        public static void Main(string[] args)
        {
            //Thread.Sleep(9000);
            log4net.Config.XmlConfigurator.Configure();

            var container = new Container();

            var COLL_POOOOORTHandlerFactory = new PortHandlerFactory(container, "Ports");
            var cfg = new CronusSettings(container)
                      .UseContractsFromAssemblies(new Assembly[]
            {
                Assembly.GetAssembly(typeof(RegisterAccount)),
                Assembly.GetAssembly(typeof(CreateUser))
            })
                      .UseRabbitMqTransport(x => x.Server = "docker-local.com")
                      .UsePortConsumer("Ports", consumable => consumable
                                       .WithDefaultPublishers()
                                       .UseAzureServiceBusTransport(x =>
            {
                x.ClientId         = "162af3b1-ed60-4382-8ce8-a1199e0b5c31";
                x.ClientSecret     = "Jej7RF6wTtgTOoqhZokc+gROk2UovFaL+zG1YF2/ous=";
                x.ResourceGroup    = "mvclientshared.integration.all";
                x.SubscriptionId   = "b12a87ce-85b9-4780-afac-cc4295574db4";
                x.TenantId         = "a43960df-8c6f-4854-8628-7f61120c33f8";
                x.ConnectionString = "Endpoint=sb://mvclientshared-integration-all-srvbus-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=BQNROS3Pw8i5YIsoAclpWbkgHrZvUdPqlJdS/RCVc9c=";
                x.Namespace        = "mvclientshared-integration-all-srvbus-namespace";
            })
                                       //.UseRabbitMqTransport(x => x.Server = "docker-local.com")
                                       .SetNumberOfConsumerThreads(5)
                                       .UsePorts(c => c.RegisterHandlersInAssembly(new[] { Assembly.GetAssembly(typeof(UserProjection)) }, COLL_POOOOORTHandlerFactory.Create)));

            (cfg as ISettingsBuilder).Build();

            host = container.Resolve <CronusHost>();
            host.Start();

            Console.WriteLine("Ports started");
            Console.ReadLine();

            host.Stop();
        }
예제 #3
0
        static void UseCronusHostWithCosmosEventStore()
        {
            var container = new Container();
            var cfg       = new CronusSettings(container)
                            .UseCluster(cluster => cluster.UseAggregateRootAtomicAction(atomic => atomic.WithInMemory()))
                            .UseContractsFromAssemblies(new[] { Assembly.GetAssembly(typeof(AccountRegistered)), Assembly.GetAssembly(typeof(UserCreated)) });

            string IAA = "IAA";
            var    IAA_appServiceFactory = new ApplicationServiceFactory(container, IAA);

            cfg.UseCommandConsumer(IAA, consumer => consumer
                                   .UseRabbitMqTransport(x => x.Server = "docker-local.com")
                                   .SetNumberOfConsumerThreads(1)
                                   .WithDefaultPublishers()
                                   .UseCosmosEventStore(eventStore => eventStore
                                                        .SetDocumentclient(new Uri("https://localhost:8081"), "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==")
                                                        .SetThroughput(2500)
                                                        .WithNewStorageIfNotExists())
                                   .UseApplicationServices(cmdHandler => cmdHandler.RegisterHandlersInAssembly(new[] { typeof(AccountAppService).Assembly }, IAA_appServiceFactory.Create)));

            string COLL = "COLL";
            var    COLL_appServiceFactory = new ApplicationServiceFactory(container, COLL);

            cfg.UseCommandConsumer(COLL, consumer => consumer
                                   .UseRabbitMqTransport(x => x.Server = "docker-local.com")
                                   .SetNumberOfConsumerThreads(1)
                                   .WithDefaultPublishers()
                                   .UseCosmosEventStore(eventStore => eventStore
                                                        .SetDocumentclient(new Uri("https://localhost:8081"), "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==")
                                                        .SetThroughput(2500)
                                                        .WithNewStorageIfNotExists())
                                   .UseApplicationServices(cmdHandler => cmdHandler.RegisterHandlersInAssembly(new[] { typeof(UserAppService).Assembly }, COLL_appServiceFactory.Create)));

            (cfg as ISettingsBuilder).Build();
            host = container.Resolve <CronusHost>();
            host.Start();
        }
예제 #4
0
        public static void Start()
        {
            try
            {
                log.Info("Starting Cronus Push Notifications");

                var appContext = new ApplicationContext("PushNotifications");
                var cfgRepo = new ConsulForPandora(new Uri("http://consul.local.com:8500"));
                var pandora = new Pandora(appContext, cfgRepo);

                container = new Container();

                new CronusSettings(container)
                     .UseCluster(cluster =>
                        cluster.UseAggregateRootAtomicAction(atomic =>
                        {
                            if (pandora.Get<bool>("enable_redis_atomic_action"))
                                atomic.UseRedis(redis => redis.SetLockEndPoints(pandora.Get("redis_endpoints").ParseIPEndPoints(";")));
                            else
                                atomic.WithInMemory();
                        }))
                     .UseAppServices(pandora)
                     .UseProjections(pandora)
                     .UsePorts(pandora)
                     .Build();

                host = container.Resolve<CronusHost>();
                host.Start();
                log.Info("STARTED Cronus Push Notifications");
            }
            catch (Exception ex)
            {
                log.ErrorException("Unable to boot PushNotifications.WS", ex);
                throw;
            }
        }
        public static void Main(string[] args)
        {
            //Thread.Sleep(9000);
            log4net.Config.XmlConfigurator.Configure();

            var container = new Container();
            var COLL_POOOOORTHandlerFactory = new PortHandlerFactory(container, null);
            var cfg = new CronusSettings(container)
                .UseContractsFromAssemblies(new Assembly[] { Assembly.GetAssembly(typeof(RegisterAccount)), Assembly.GetAssembly(typeof(CreateUser)) })
                .UsePortConsumer(consumable => consumable
                    .WithDefaultPublishersWithRabbitMq()
                    .UseRabbitMqTransport()
                    .SetNumberOfConsumerThreads(5)
                    .UsePorts(c => c.RegisterAllHandlersInAssembly(Assembly.GetAssembly(typeof(UserProjection)), COLL_POOOOORTHandlerFactory.Create)));

            (cfg as ISettingsBuilder).Build();
            host = container.Resolve<CronusHost>();
            host.Start();

            Console.WriteLine("Ports started");
            Console.ReadLine();

            host.Stop();
        }
        static void UseCronusHostWithCassandraEventStore()
        {
            var container = new Container();
            var cfg       = new CronusSettings(container)
                            .UseCluster(cluster =>
            {
                cluster.ClusterName     = "playground";
                cluster.CurrentNodeName = "node1";
                cluster.UseAggregateRootAtomicAction(atomic => atomic.WithInMemory());
            })
                            .UseContractsFromAssemblies(new[] { Assembly.GetAssembly(typeof(AccountRegistered)), Assembly.GetAssembly(typeof(UserCreated)), Assembly.GetAssembly(typeof(ProjectionVersionManagerId)) });

            string SYSTEM = "SYSTEM";
            var    SYSTEM_appServiceFactory = new ServiceLocator(container, SYSTEM);

            cfg.UseCommandConsumer(SYSTEM, consumer => consumer
                                   .UseAzureServiceBusTransport(x =>
            {
                x.ClientId         = "162af3b1-ed60-4382-8ce8-a1199e0b5c31";
                x.ClientSecret     = "Jej7RF6wTtgTOoqhZokc+gROk2UovFaL+zG1YF2/ous=";
                x.ResourceGroup    = "mvclientshared.integration.all";
                x.SubscriptionId   = "b12a87ce-85b9-4780-afac-cc4295574db4";
                x.TenantId         = "a43960df-8c6f-4854-8628-7f61120c33f8";
                x.ConnectionString = "Endpoint=sb://mvclientshared-integration-all-srvbus-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=BQNROS3Pw8i5YIsoAclpWbkgHrZvUdPqlJdS/RCVc9c=";
                x.Namespace        = "mvclientshared-integration-all-srvbus-namespace";
            })
                                   //.UseRabbitMqTransport(x => x.Server = "docker-local.com")
                                   .WithDefaultPublishers()
                                   .UseCassandraEventStore(eventStore => eventStore
                                                           .SetConnectionString(ConfigurationManager.ConnectionStrings["cronus_es"].ConnectionString)
                                                           .SetAggregateStatesAssembly(typeof(ProjectionVersionManagerAppService)))
                                   .UseSystemServices(cmdHandler => cmdHandler.RegisterHandlersInAssembly(new[] { typeof(ProjectionVersionManagerAppService).Assembly }, SYSTEM_appServiceFactory.Resolve))
                                   );

            //Endpoint = sb://mvclientshared-integration-all-srvbus-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=BQNROS3Pw8i5YIsoAclpWbkgHrZvUdPqlJdS/RCVc9c=
            string IAA = "IAA";
            var    IAA_appServiceFactory = new ServiceLocator(container, IAA);

            cfg.UseCommandConsumer(IAA, consumer => consumer
                                   .UseAzureServiceBusTransport(x =>
            {
                x.ClientId         = "162af3b1-ed60-4382-8ce8-a1199e0b5c31";
                x.ClientSecret     = "Jej7RF6wTtgTOoqhZokc+gROk2UovFaL+zG1YF2/ous=";
                x.ResourceGroup    = "mvclientshared.integration.all";
                x.SubscriptionId   = "b12a87ce-85b9-4780-afac-cc4295574db4";
                x.TenantId         = "a43960df-8c6f-4854-8628-7f61120c33f8";
                x.ConnectionString = "Endpoint=sb://mvclientshared-integration-all-srvbus-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=BQNROS3Pw8i5YIsoAclpWbkgHrZvUdPqlJdS/RCVc9c=";
                x.Namespace        = "mvclientshared-integration-all-srvbus-namespace";
            })
                                   //.UseRabbitMqTransport(x => x.Server = "docker-local.com")
                                   //.UseAzureServiceBus
                                   .SetNumberOfConsumerThreads(5)
                                   .WithDefaultPublishers()
                                   .UseCassandraEventStore(eventStore => eventStore
                                                           .SetConnectionString(ConfigurationManager.ConnectionStrings["cronus_es"].ConnectionString)
                                                           .SetAggregateStatesAssembly(typeof(AccountState)))
                                   .UseApplicationServices(cmdHandler => cmdHandler.RegisterHandlersInAssembly(new[] { typeof(AccountAppService).Assembly }, IAA_appServiceFactory.Resolve))
                                   );

            string COLL = "COLL";
            var    COLL_appServiceFactory = new ServiceLocator(container, COLL);

            cfg.UseCommandConsumer(COLL, consumer => consumer
                                   .UseAzureServiceBusTransport(x =>
            {
                x.ClientId         = "162af3b1-ed60-4382-8ce8-a1199e0b5c31";
                x.ClientSecret     = "Jej7RF6wTtgTOoqhZokc+gROk2UovFaL+zG1YF2/ous=";
                x.ResourceGroup    = "mvclientshared.integration.all";
                x.SubscriptionId   = "b12a87ce-85b9-4780-afac-cc4295574db4";
                x.TenantId         = "a43960df-8c6f-4854-8628-7f61120c33f8";
                x.ConnectionString = "Endpoint=sb://mvclientshared-integration-all-srvbus-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=BQNROS3Pw8i5YIsoAclpWbkgHrZvUdPqlJdS/RCVc9c=";
                x.Namespace        = "mvclientshared-integration-all-srvbus-namespace";
            })
                                   //.UseRabbitMqTransport(x => x.Server = "docker-local.com")
                                   .SetNumberOfConsumerThreads(5)
                                   .WithDefaultPublishers()
                                   .UseCassandraEventStore(eventStore => eventStore
                                                           .SetConnectionString(ConfigurationManager.ConnectionStrings["cronus_es"].ConnectionString)
                                                           .SetAggregateStatesAssembly(typeof(UserState)))
                                   .UseApplicationServices(cmdHandler => cmdHandler.RegisterHandlersInAssembly(new[] { typeof(UserAppService).Assembly }, COLL_appServiceFactory.Resolve))
                                   );

            (cfg as ISettingsBuilder).Build();
            host = container.Resolve <CronusHost>();
            host.Start();
        }
        public static void Main(string[] args)
        {
            log4net.Config.XmlConfigurator.Configure();

            //var sf = BuildSessionFactory();
            var container      = new Container();
            var serviceLocator = new ServiceLocator(container);

            //var projectionTypes = typeof(UserProjection).Assembly.GetTypes().Where(x => typeof(IProjectionDefinition).IsAssignableFrom(x));
            var systemProjections        = typeof(PersistentProjectionVersionHandler).Assembly.GetTypes().Where(x => typeof(IProjectionDefinition).IsAssignableFrom(x)).ToList();
            var collaborationProjections = typeof(Collaboration.Users.Projections.UserProjection).Assembly.GetTypes().Where(x => typeof(IProjectionDefinition).IsAssignableFrom(x));

            systemProjections.AddRange(collaborationProjections);

            var cfg = new CronusSettings(container)
                      .UseCluster(cluster =>
            {
                cluster.ClusterName     = "playground";
                cluster.CurrentNodeName = "node1";
            })
                      .UseContractsFromAssemblies(new Assembly[] { Assembly.GetAssembly(typeof(RegisterAccount)), Assembly.GetAssembly(typeof(CreateUser)) });

            var projection_serviceLocator = new ServiceLocator(container, "Projection");

            cfg.UseProjectionConsumer("Projection", consumer => consumer
                                      .WithDefaultPublishers()
                                      .SetNumberOfConsumerThreads(5)
                                      .UseAzureServiceBusTransport(x =>
            {
                x.ClientId         = "162af3b1-ed60-4382-8ce8-a1199e0b5c31";
                x.ClientSecret     = "Jej7RF6wTtgTOoqhZokc+gROk2UovFaL+zG1YF2/ous=";
                x.ResourceGroup    = "mvclientshared.integration.all";
                x.SubscriptionId   = "b12a87ce-85b9-4780-afac-cc4295574db4";
                x.TenantId         = "a43960df-8c6f-4854-8628-7f61120c33f8";
                x.ConnectionString = "Endpoint=sb://mvclientshared-integration-all-srvbus-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=BQNROS3Pw8i5YIsoAclpWbkgHrZvUdPqlJdS/RCVc9c=";
                x.Namespace        = "mvclientshared-integration-all-srvbus-namespace";
            })
                                      //.UseRabbitMqTransport(x => x.Server = "docker-local.com")
                                      .UseProjections(h => h
                                                      .RegisterHandlerTypes(systemProjections, projection_serviceLocator.Resolve)
                                                      .UseCassandraProjections(x => x
                                                                               .SetProjectionsConnectionString("Contact Points=docker-local.com;Port=9042;Default Keyspace=cronus_sample_20180213")
                                                                               .SetProjectionTypes(systemProjections))
                                                      ));

            var systemSaga_serviceLocator = new ServiceLocator(container, "SystemSaga");

            cfg.UseSagaConsumer("SystemSaga", consumer => consumer
                                .WithDefaultPublishers()
                                .UseAzureServiceBusTransport(x =>
            {
                x.ClientId         = "162af3b1-ed60-4382-8ce8-a1199e0b5c31";
                x.ClientSecret     = "Jej7RF6wTtgTOoqhZokc+gROk2UovFaL+zG1YF2/ous=";
                x.ResourceGroup    = "mvclientshared.integration.all";
                x.SubscriptionId   = "b12a87ce-85b9-4780-afac-cc4295574db4";
                x.TenantId         = "a43960df-8c6f-4854-8628-7f61120c33f8";
                x.ConnectionString = "Endpoint=sb://mvclientshared-integration-all-srvbus-namespace.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=BQNROS3Pw8i5YIsoAclpWbkgHrZvUdPqlJdS/RCVc9c=";
                x.Namespace        = "mvclientshared-integration-all-srvbus-namespace";
            })
                                //.UseRabbitMqTransport(x => x.Server = "docker-local.com")
                                .ConfigureCassandraProjectionsStore(proj => proj
                                                                    .SetProjectionTypes(typeof(ProjectionBuilder).Assembly)
                                                                    .SetProjectionsConnectionString("Contact Points=docker-local.com;Port=9042;Default Keyspace=cronus_sample_20180213"))
                                .UseCassandraEventStore(eventStore => eventStore
                                                        .SetConnectionString(ConfigurationManager.ConnectionStrings["cronus_es"].ConnectionString)
                                                        .SetAggregateStatesAssembly(typeof(Elders.Cronus.Sample.Collaboration.Users.UserState)))
                                .UseSystemSagas(saga => saga.RegisterHandlerTypes(new List <Type>()
            {
                typeof(ProjectionBuilder)
            }, systemSaga_serviceLocator.Resolve))
                                );

            //var systemProjectionTypes = typeof(PersistentProjectionVersionHandler).Assembly.GetTypes().Where(x => typeof(IProjectionDefinition).IsAssignableFrom(x));
            //var systemProj_serviceLocator = new ServiceLocator(container, "SystemProj");
            //cfg.UseProjectionConsumer("SystemProj", consumer => consumer
            //     .WithDefaultPublishers()
            //     .UseRabbitMqTransport(x => x.Server = "docker-local.com")
            //     .UseSystemProjections(h => h
            //        .RegisterHandlerTypes(systemProjectionTypes, systemProj_serviceLocator.Resolve)
            //        .UseCassandraProjections(p => p
            //            .SetProjectionsConnectionString("Contact Points=docker-local.com;Port=9042;Default Keyspace=cronus_sample_20180213")
            //            .SetProjectionTypes(typeof(PersistentProjectionVersionHandler).Assembly)
            //                ))
            //    );

            (cfg as ISettingsBuilder).Build();
            host = container.Resolve <CronusHost>();
            host.Start();

            Console.WriteLine("Projections started");
            Console.ReadLine();
            host.Stop();
        }