コード例 #1
0
ファイル: Program.cs プロジェクト: barbatron/converge
        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;
        }
コード例 #2
0
 public static TransportSettings UseRabbitMq(string host)
 {
     TransportSettings ts = new TransportSettings
     {
         PrimaryHost = host,
         ProtocolUriPrefix = "rabbitmq"
     };
     ts.AddGlobalSbc(sbc => sbc.UseRabbitMq());
     return ts;
 }
コード例 #3
0
        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();
        }
コード例 #4
0
        public static NodeContext ConnectNode(string host, NodeRecord node,
             Func<object, object> transportSpecificQueueNameTranslator,
            Action<ServiceBusConfigurator> customBusConfiguration = null)
        {
            transportSpecificQueueNameTranslator = transportSpecificQueueNameTranslator ?? MsmqTransportTranslator;
            dynamic queueSpecs = transportSpecificQueueNameTranslator(new
            {
                Format = "uri",
                Host = host,
                NodeRecord = node
            });

            Uri receiveFromUri = new Uri(queueSpecs.Uri);
            Action<ServiceBusConfigurator> sbcOps = queueSpecs.SBCAdjustments;
            TransportSettings ts = new TransportSettings
            {
                PrimaryHost = host,
                ProtocolUriPrefix = queueSpecs.Prefix
            };

            var serviceBus = ServiceBusFactory.New(sbc =>
            {
                sbc.ReceiveFrom(receiveFromUri);
                
                sbcOps(sbc);

                sbc.UseControlBus();
                //sbc.EnableRemoteIntrospection();

                if (customBusConfiguration != null)
                    customBusConfiguration(sbc);
            });



            return new NodeContext
            {
                Record = node,
                Bus = serviceBus,
                QueueName = queueSpecs.QueueName,
                Settings = ts
            };

        }
コード例 #5
0
        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;
        }
コード例 #6
0
 public void Configure(TransportSettings settings)
 {
     StartSubscriptionService(settings);
     StartTimeoutService(settings);
 }