Пример #1
0
        public void Start()
        {
            Log.Assign(new Log4NetLog(LogManager.GetLogger(typeof(Host))));

            _container = new WindsorContainer();

            _container.RegisterDataAccessCore();
            _container.RegisterDataAccess("Shuttle.ProcessManagement");

            _container.Register(Component.For <IEventStore>().ImplementedBy <EventStore>());
            _container.Register(Component.For <IKeyStore>().ImplementedBy <KeyStore>());
            _container.Register(Component.For <ISerializer>().ImplementedBy <DefaultSerializer>());
            _container.Register(Component.For <IEventStoreQueryFactory>().ImplementedBy <EventStoreQueryFactory>());
            _container.Register(Component.For <IKeyStoreQueryFactory>().ImplementedBy <KeyStoreQueryFactory>());

            var subscriptionManager = SubscriptionManager.Default();

            subscriptionManager.Subscribe <OrderCreatedEvent>();
            subscriptionManager.Subscribe <InvoiceCreatedEvent>();
            subscriptionManager.Subscribe <EMailSentEvent>();

            var processConfiguration = ProcessSection.Configuration();

            ((DefaultProcessActivator)processConfiguration.ProcessActivator).RegisterMappings();

            _bus = ServiceBus.Create(
                c =>
            {
                c.MessageHandlerFactory(new CastleMessageHandlerFactory(_container));
                c.SubscriptionManager(subscriptionManager);
                c.AddModule(new ProcessModule(_container.Resolve <IDatabaseContextFactory>(), _container.Resolve <IEventStore>(), _container.Resolve <IKeyStore>(), processConfiguration));
            }).Start();
        }
Пример #2
0
        public void Scanner_ReadsFeedsAndSendsMessagesToTheBus()
        {
            var smRegistry = new Registry();
            var registry   = new StructureMapComponentRegistry(
                smRegistry);

            ServiceBus.Register(registry);

            var bus = ServiceBus.Create(
                resolver: new StructureMapComponentResolver(
                    new Container(smRegistry)))
                      .Start();

            var feed = new Feed
            {
                Name = "NFL",
                Url  = "http://www.rotoworld.com/tools/rss/fantasy-football.aspx",
            };
            var feedQueryHandler = new FeedReaderQueryHandler();

            var scanner = new InternetRssScanner(
                bus: bus,
                feedQueryHandler: feedQueryHandler,
                gotItQuery: new FakeGotItQuery(),
                logger: new FakeLogger());

            //  scan this feed
            var query = new FeedReaderQuery(feed);

            scanner.Scan(query);
        }
Пример #3
0
        public void Start()
        {
            Log.Assign(new Log4NetLog(LogManager.GetLogger(typeof(Host))));

            _container = new WindsorContainer();

            _container.RegisterDataAccessCore();
            _container.RegisterDataAccess("Shuttle.ProcessManagement");

            var subscriptionManager = SubscriptionManager.Default();

            subscriptionManager.Subscribe <OrderProcessRegisteredEvent>();
            subscriptionManager.Subscribe <OrderProcessCancelledEvent>();
            subscriptionManager.Subscribe <OrderProcessAcceptedEvent>();
            subscriptionManager.Subscribe <OrderProcessCompletedEvent>();
            subscriptionManager.Subscribe <OrderProcessArchivedEvent>();
            subscriptionManager.Subscribe <OrderCreatedEvent>();
            subscriptionManager.Subscribe <CancelOrderProcessRejectedEvent>();
            subscriptionManager.Subscribe <ArchiveOrderProcessRejectedEvent>();
            subscriptionManager.Subscribe <InvoiceCreatedEvent>();
            subscriptionManager.Subscribe <EMailSentEvent>();

            _bus = ServiceBus.Create(
                c =>
            {
                c
                .MessageHandlerFactory(new CastleMessageHandlerFactory(_container))
                .SubscriptionManager(subscriptionManager);
            }).Start();
        }
Пример #4
0
        public void Start()
        {
            Log.Assign(new Log4NetLog(LogManager.GetLogger(typeof(Host))));

            _container = new WindsorContainer();

            _container.RegisterDataAccessCore();
            _container.RegisterDataAccess("Shuttle.ProcessManagement");

            _container.Register(Component.For <IEventStore>().ImplementedBy <EventStore>());
            _container.Register(Component.For <Recall.Core.ISerializer>().ImplementedBy <Recall.Core.DefaultSerializer>());
            _container.Register(Component.For <IEventStoreQueryFactory>().ImplementedBy <EventStoreQueryFactory>());

            var subscriptionManager = SubscriptionManager.Default();

            subscriptionManager.Subscribe <OrderCreatedEvent>();
            subscriptionManager.Subscribe <InvoiceCreatedEvent>();
            subscriptionManager.Subscribe <EMailSentEvent>();

            _bus = ServiceBus.Create(
                c =>
            {
                c
                .MessageHandlerFactory(new CastleMessageHandlerFactory(_container).RegisterHandlers())
                .SubscriptionManager(subscriptionManager);
            }).Start();
        }
Пример #5
0
        public void Start()
        {
            Log.Assign(new Log4NetLog(LogManager.GetLogger(typeof(Host))));

            _container = new WindsorContainer();

            var container = new WindsorComponentContainer(_container);

            container.RegisterSuffixed("Shuttle.ProcessManagement");

            ServiceBus.Register(container);

            var subscriptionManager = container.Resolve <ISubscriptionManager>();

            subscriptionManager.Subscribe <OrderProcessRegisteredEvent>();
            subscriptionManager.Subscribe <OrderProcessCancelledEvent>();
            subscriptionManager.Subscribe <OrderProcessAcceptedEvent>();
            subscriptionManager.Subscribe <OrderProcessCompletedEvent>();
            subscriptionManager.Subscribe <OrderProcessArchivedEvent>();
            subscriptionManager.Subscribe <OrderCreatedEvent>();
            subscriptionManager.Subscribe <CancelOrderProcessRejectedEvent>();
            subscriptionManager.Subscribe <ArchiveOrderProcessRejectedEvent>();
            subscriptionManager.Subscribe <InvoiceCreatedEvent>();
            subscriptionManager.Subscribe <EMailSentEvent>();

            _bus = ServiceBus.Create(container).Start();
        }
Пример #6
0
        public void Start()
        {
            DbProviderFactories.RegisterFactory("System.Data.SqlClient", SqlClientFactory.Instance);

            Log.Assign(new Log4NetLog(LogManager.GetLogger(typeof(Host))));

            _container = new WindsorContainer();

            var container = new WindsorComponentContainer(_container);

            container.RegisterSuffixed("Shuttle.Abacus");

            EventStore.Register(container);
            ServiceBus.Register(container);

            container.Register <ArgumentHandler>();
            container.Register <FormulaHandler>();
            container.Register <MatrixHandler>();
            container.Register <TestHandler>();

            _eventProcessor = container.Resolve <IEventProcessor>();

            _eventProcessor.AddProjection(new Projection("Argument").AddEventHandler(container.Resolve <ArgumentHandler>()));
            _eventProcessor.AddProjection(new Projection("Formula").AddEventHandler(container.Resolve <FormulaHandler>()));
            _eventProcessor.AddProjection(new Projection("Matrix").AddEventHandler(container.Resolve <MatrixHandler>()));
            _eventProcessor.AddProjection(new Projection("Test").AddEventHandler(container.Resolve <TestHandler>()));

            container.Resolve <IDatabaseContextFactory>().ConfigureWith("Abacus");

            _bus = ServiceBus.Create(container).Start();
            _eventProcessor.Start();
        }
Пример #7
0
        private static void Main()
        {
            Log.Assign(new Log4NetLog(LogManager.GetLogger(typeof(Program))));

            var bus = ServiceBus
                      .Create()
                      .AddCompressionAlgorithm(new GZipCompressionAlgorithm())
                      .AddEnryptionAlgorithm(new TripleDesEncryptionAlgorithm())
                      .Start();

            Console.WriteLine("Client bus started.  Press CTRL+C to stop.");
            Console.WriteLine();
            Console.WriteLine("Press enter to send a message with random text to the server for reversal.");
            Console.WriteLine();

            while (true)
            {
                Console.ReadLine();

                var command = new ReverseTextCommand
                {
                    Text = Guid.NewGuid().ToString().Substring(0, 5)
                };

                bus.OutgoingCorrelationId = "correlation-id";
                bus.OutgoingHeaders.Add(new TransportHeader {
                    Key = "header1", Value = "value1"
                });
                bus.OutgoingHeaders.Add(new TransportHeader {
                    Key = "header2", Value = "value2"
                });

                Console.WriteLine("Message (id: {0}) sent.  Text: {1}", bus.Send(command).MessageId, command.Text);
            }
        }
Пример #8
0
        static void Main(string[] args)
        {
            using (var bus = ServiceBus.Create().Start())
            {
                string userName;

                while (!string.IsNullOrEmpty(userName = Console.ReadLine()))
                {
                    var command = new RegisterMemberCommand
                    {
                        UserName = userName
                    };

                    var transportMessage = bus.CreateTransportMessage(command, null);

                    for (var i = 0; i < 5; i++)
                    {
                        bus.Dispatch(transportMessage);                         // will be processed once since message id is the same
                    }

                    bus.Send(command);                     // will be processed since it has a new message id
                    bus.Send(command);                     // will also be processed since it also has a new message id
                }
            }
        }
Пример #9
0
        private static void Main(string[] args)
        {
            var container = new SimpleInjectorComponentContainer(new Container());

            ServiceBus.Register(container);

            var transportMessageFactory = container.Resolve <ITransportMessageFactory>();

            using (var bus = ServiceBus.Create(container).Start())
            {
                string userName;

                while (!string.IsNullOrEmpty(userName = Console.ReadLine()))
                {
                    var command = new RegisterMemberCommand
                    {
                        UserName = userName
                    };

                    var transportMessage = transportMessageFactory.Create(command, c => { });

                    for (var i = 0; i < 5; i++)
                    {
                        bus.Dispatch(transportMessage);                         // will be processed once since message id is the same
                    }

                    bus.Send(command);                     // will be processed since it has a new message id
                    bus.Send(command);                     // will also be processed since it too has a new message id
                }
            }
        }
        public virtual void Start()
        {
            // init logging
            Log.Assign(new ConsoleLog(typeof(ShuttleESBHost))
            {
                LogLevel = LogLevel.Trace
            });

            // init depedency injection container
            InitializeContainer();

            // init message handler factory
            var messageHandlerFactory = InitializeMessageHandlerFactory();

            // init subscription manager
            var subscriptionManager = InitializeSubscriptionManager();

            // init message serializer
            var messageSerializer = InitializeMessageSerializer();

            // init compression algorithm
            var compressionAlgorithm = InitializeCompressionAlgorithm();

            // init encryption algorithm
            var encryptionAlgorithm = InitializeEncryptionAlgorithm();

            // start service bus
            Bus = ServiceBus
                  .Create(c =>
            {
                if (subscriptionManager != null)
                {
                    c.SubscriptionManager(subscriptionManager);
                }

                if (messageHandlerFactory != null)
                {
                    c.MessageHandlerFactory(messageHandlerFactory);
                }

                if (messageSerializer != null)
                {
                    c.MessageSerializer(messageSerializer);
                }

                if (compressionAlgorithm != null)
                {
                    c.AddCompressionAlgorithm(compressionAlgorithm);
                }

                if (encryptionAlgorithm != null)
                {
                    c.AddEnryptionAlgorithm(encryptionAlgorithm);
                }
            });

            Contract.Assume(Bus != null);

            Bus.Start();
        }
Пример #11
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddCors();

            var container = new WindsorContainer();

            var componentContainer = new WindsorComponentContainer(container);

            componentContainer.RegisterInstance <IAccessConfiguration>(AccessSection.Configuration());

            componentContainer.RegisterSuffixed("Shuttle.Sentinel");
            componentContainer.RegisterSuffixed("Shuttle.Access.Sql");

            componentContainer.Register <IInspectionQueue, DefaultInspectionQueue>();
            componentContainer.Register <IHttpContextAccessor, HttpContextAccessor>();
            componentContainer.Register <IDatabaseContextCache, ContextDatabaseContextCache>();

            ServiceBus.Register(componentContainer);
            EventStore.Register(componentContainer);

            componentContainer.Resolve <IDataStoreDatabaseContextFactory>().ConfigureWith("Sentinel");
            componentContainer.Resolve <IDatabaseContextFactory>().ConfigureWith("Sentinel");
            var inspectionQueue = componentContainer.Resolve <IInspectionQueue>();

            _bus = ServiceBus.Create(componentContainer).Start();

            return(WindsorRegistrationHelper.CreateServiceProvider(container, services));
        }
Пример #12
0
        public void Start()
        {
            var container = new WindsorComponentContainer(new WindsorContainer());

            ServiceBus.Register(container);

            _bus = ServiceBus.Create(container).Start();
        }
Пример #13
0
        public void Start()
        {
            var subscriptionManager = SubscriptionManager.Default();

            subscriptionManager.Subscribe <MemberRegisteredEvent>();

            _bus = ServiceBus.Create(c => c.SubscriptionManager(subscriptionManager)).Start();
        }
Пример #14
0
        public void Start()
        {
            Log.Assign(new ConsoleLog(GetType())
            {
                LogLevel = LogLevel.Trace
            });

            _bus = ServiceBus.Create().Start();
        }
Пример #15
0
        public void Start()
        {
            var smRegistry = new Registry();
            var registry   = new StructureMapComponentRegistry(smRegistry);

            ServiceBus.Register(registry);

            _bus = ServiceBus.Create(new StructureMapComponentResolver(new Container(smRegistry))).Start();
        }
Пример #16
0
        public void Start()
        {
            _container = new WindsorContainer();

            _container.Register(Component.For <IEMailService>().ImplementedBy <EMailService>());

            // also calls RegisterHandlers to register handlers in this assembly
            _bus = ServiceBus.Create(
                c => c.MessageHandlerFactory(new CastleMessageHandlerFactory(_container).RegisterHandlers(Assembly.GetExecutingAssembly()))
                ).Start();
        }
Пример #17
0
        public void Start()
        {
            Log4NetConfig.Init(true);

            Log.Assign(new Log4NetLog(LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType)));

            this.bus = ServiceBus
                       .Create(c => c.AddEnryptionAlgorithm(new TripleDesEncryptionAlgorithm())
                               .AddCompressionAlgorithm(new DeflateCompressionAlgorithm()))
                       .Start();
        }
Пример #18
0
        public void Start()
        {
            Log.Assign(new Log4NetLog(LogManager.GetLogger(typeof(Host))));

            var containerBuilder = new ContainerBuilder();
            var registry         = new AutofacComponentRegistry(containerBuilder);

            ServiceBus.Register(registry);

            _bus = ServiceBus.Create(new AutofacComponentResolver(containerBuilder.Build())).Start();
        }
Пример #19
0
        public void Start()
        {
            Log.Assign(new Log4NetLog(LogManager.GetLogger(typeof(ServiceBusHost))));

            bus = ServiceBus
                  .Create()
                  .AddEnryptionAlgorithm(new TripleDesEncryptionAlgorithm())
                  .AddCompressionAlgorithm(new GZipCompressionAlgorithm())
                  .AddModule(new ActiveTimeRangeModule())
                  .Start();
        }
Пример #20
0
        public void Start()
        {
            var containerBuilder = new ContainerBuilder();
            var registry         = new AutofacComponentRegistry(containerBuilder);

            ServiceBus.Register(registry);

            var resolver = new AutofacComponentResolver(containerBuilder.Build());

            _bus = ServiceBus.Create(resolver).Start();
        }
Пример #21
0
        public void Start()
        {
            Log.Assign(new Log4NetLog(LogManager.GetLogger(typeof(Host))));

            _container = new WindsorContainer();

            var container = new WindsorComponentContainer(_container);

            ServiceBus.Register(container);

            _bus = ServiceBus.Create(container).Start();
        }
Пример #22
0
        public void Start()
        {
            Log.Assign(new Log4NetLog(LogManager.GetLogger(typeof(Host))));

            _container = new WindsorContainer();

            _bus = ServiceBus.Create(
                c => c
                .MessageHandlerFactory(new CastleMessageHandlerFactory(_container).RegisterHandlers())
                .SubscriptionManager(SubscriptionManager.Default())
                ).Start();
        }
Пример #23
0
        public void Start()
        {
            _kernel = new StandardKernel();

            _kernel.Bind <IEMailService>().To <EMailService>();

            var container = new NinjectComponentContainer(_kernel);

            ServiceBus.Register(container);

            _bus = ServiceBus.Create(container).Start();
        }
Пример #24
0
        public void Start()
        {
            _kernel = new StandardKernel();

            var container = new NinjectComponentContainer(_kernel);

            ServiceBus.Register(container);

            container.Resolve <ISubscriptionManager>().Subscribe <DocumentProcessedEvent>();

            _bus = ServiceBus.Create(container).Start();
        }
Пример #25
0
        static void Main(string[] args)
        {
            var container = new NinjectComponentContainer(new StandardKernel());

            ServiceBus.Register(container);

            using (ServiceBus.Create(container).Start())
            {
                Console.WriteLine("Server started... Ctrl+C to exit.");
                Console.ReadKey();
            }
        }
Пример #26
0
 static void Main(string[] args)
 {
     using (var bus = ServiceBus
                      .Create(c => c.AddEnryptionAlgorithm(new TripleDesEncryptionAlgorithm())
                              .AddCompressionAlgorithm(new DeflateCompressionAlgorithm()))
                      .Start())
     {
         bus.Send(new RegisterUserCommand {
             Name = "SuperUser"
         });
     }
 }
Пример #27
0
        public void Start()
        {
            var structureMapRegistry = new Registry();
            var registry             = new StructureMapComponentRegistry(structureMapRegistry);

            ServiceBus.Register(registry);

            var resolver = new StructureMapComponentResolver(new Container(structureMapRegistry));

            resolver.Resolve <ISubscriptionManager>().Subscribe <MemberRegisteredEvent>();

            _bus = ServiceBus.Create(resolver).Start();
        }
Пример #28
0
        public void Start()
        {
            Log.Assign(new ConsoleLog(typeof(ServiceBusHost))
            {
                LogLevel = LogLevel.Trace
            });

            bus = ServiceBus
                  .Create()
                  .AddEnryptionAlgorithm(new TripleDesEncryptionAlgorithm())
                  .AddCompressionAlgorithm(new GZipCompressionAlgorithm())
                  .Start();
        }
Пример #29
0
 static void Main(string[] args)
 {
     using (var bus = ServiceBus.Create().Start())
     {
         string username;
         while (!string.IsNullOrEmpty(username = Console.ReadLine()))
         {
             bus.Send(new RegisterMemberCommand
             {
                 UserName = username
             });
         }
     }
 }
Пример #30
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              IApplicationLifetime applicationLifetime)
        {
            var container = app.ApplicationServices.GetService <IWindsorContainer>();

            var componentContainer = new WindsorComponentContainer(container);

            componentContainer.RegisterSuffixed("Shuttle.Sentinel");
            componentContainer.RegisterSuffixed("Shuttle.Access.Sql");
            componentContainer.RegisterSuffixed("Shuttle.Esb.Scheduling");

            componentContainer.Register <IInspectionQueue, DefaultInspectionQueue>();
            componentContainer.Register <IHttpContextAccessor, HttpContextAccessor>();
            componentContainer.Register <IDatabaseContextCache, ContextDatabaseContextCache>();
            componentContainer.Register <IHashingService, HashingService>();

            componentContainer.RegisterInstance(app.ApplicationServices.GetService <IAccessConfiguration>());
            componentContainer.RegisterInstance(app.ApplicationServices.GetService <ISentinelConfiguration>());

            var applicationPartManager = app.ApplicationServices.GetRequiredService <ApplicationPartManager>();
            var controllerFeature      = new ControllerFeature();

            applicationPartManager.PopulateFeature(controllerFeature);

            foreach (var type in controllerFeature.Controllers.Select(t => t.AsType()))
            {
                componentContainer.Register(type, type);
            }

            ServiceBus.Register(componentContainer);

            componentContainer.Resolve <IDataStoreDatabaseContextFactory>().ConfigureWith("Sentinel");
            componentContainer.Resolve <IDatabaseContextFactory>().ConfigureWith("Sentinel");

            _bus = ServiceBus.Create(componentContainer).Start();

            applicationLifetime.ApplicationStopping.Register(OnShutdown);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseCors(
                options => options.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()
                );

            app.UseMvc();
        }