Пример #1
0
        private static IContainer BootstrapContainer(TransportSettings transportSettings, string appNameBase)
        {
            ObjectFactory.Initialize(cfg =>
                {
                    cfg.AddRegistry<CentralMonRegistry>();

                    cfg.For<TransportSettings>().Singleton().Use(transportSettings);

                    cfg.For<IServiceBus>().Use(context => ServiceBusFactory.New(sbc =>
                    {
                        string rcvQueueUri = transportSettings.GetQueueUri(appNameBase);
                        sbc.ReceiveFrom(rcvQueueUri);

                        transportSettings.ApplyGlobalConfig(sbc);

                        sbc.UseControlBus();

                        sbc.Subscribe(sub =>
                            {
                                sub.LoadFrom(ObjectFactory.Container);
                            });

                    }));

                });

            var container = ObjectFactory.Container;
            CentralMonRegistry.Build(container);
            return container;
        }
        private void StartTimeoutService(TransportSettings settings)
        {
            //
            // setup the time out service
            //
            string subscriptionQueueUri = settings.GetQueueUri(SubscriptionServiceQueueName ?? STR_DefaultSubscriptionServiceQueueName);
            string timeoutQueueUri = settings.GetQueueUri(TimeoutServiceQueueName ?? STR_DefaultTimeoutServiceQueueName);
            var timeoutBus = ServiceBusFactory.New(sbc =>
            {
                sbc.UseControlBus();

                sbc.ReceiveFrom(timeoutQueueUri);
                sbc.UseSubscriptionService(subscriptionQueueUri);
            });

            var timeoutService = new TimeoutService(timeoutBus, new InMemorySagaRepository<TimeoutSaga>());
            timeoutService.Start();
        }
        private string StartSubscriptionService(TransportSettings settings)
        {
            string subscriptionQueueUri = settings.GetQueueUri(SubscriptionServiceQueueName ?? STR_DefaultSubscriptionServiceQueueName);

            //
            // setup the subscription service
            //
            var subscriptionBus = ServiceBusFactory.New(sbc =>
            {
                sbc.UseRabbitMq();
                sbc.SetConcurrentConsumerLimit(1);

                sbc.ReceiveFrom(subscriptionQueueUri);
            });

            var subscriptionSagas = new InMemorySagaRepository<SubscriptionSaga>();
            var subscriptionClientSagas = new InMemorySagaRepository<SubscriptionClientSaga>();
            var subscriptionService = new SubscriptionService(subscriptionBus, subscriptionSagas, subscriptionClientSagas);

            subscriptionService.Start();
            return subscriptionQueueUri;
        }