示例#1
0
        public bool Start(HostControl hostControl)
        {
            this.log.Info("Creating bus...");

            this.metrics         = new RoutingSlipMetrics("Routing Slip");
            this.activityMetrics = new RoutingSlipMetrics("Validate Activity");

            this.machine        = new RoutingSlipStateMachine();
            this.provider       = new SqLiteSessionFactoryProvider(false, typeof(RoutingSlipStateSagaMap));
            this.sessionFactory = this.provider.GetSessionFactory();

            this.repository = new NHibernateSagaRepository <RoutingSlipState>(this.sessionFactory);

            this.busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                var host = x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                x.UseSerilog();

                x.EnabledPerformanceCounters();

                x.ReceiveEndpoint(host, "routing_slip_metrics", e =>
                {
                    e.PrefetchCount = 100;
                    e.UseRetry(Retry.None);
                    e.Consumer(() => new RoutingSlipMetricsConsumer(this.metrics));
                });

                x.ReceiveEndpoint(host, "routing_slip_activity_metrics", e =>
                {
                    e.PrefetchCount = 100;
                    e.UseRetry(Retry.None);
                    e.Consumer(() => new RoutingSlipActivityConsumer(this.activityMetrics, "Validate"));
                });

                x.ReceiveEndpoint(host, "routing_slip_state", e =>
                {
                    e.PrefetchCount = 8;
                    e.UseConcurrencyLimit(1);
                    e.StateMachineSaga(this.machine, this.repository);
                });
            });

            this.log.Info("Starting bus...");

            this.busControl.Start();

            return(true);
        }
        public bool Start(HostControl hostControl)
        {
            _log.Info("Creating bus...");

            _metrics         = new RoutingSlipMetrics("Routing Slip");
            _activityMetrics = new RoutingSlipMetrics("Validate Activity");

            _machine = new RoutingSlipStateMachine();

            SagaDbContextFactory sagaDbContextFactory =
                () => new SagaDbContext <RoutingSlipState, RoutingSlipStateSagaMap>(SagaDbContextFactoryProvider.ConnectionString);

            _repository = new Lazy <ISagaRepository <RoutingSlipState> >(
                () => new EntityFrameworkSagaRepository <RoutingSlipState>(sagaDbContextFactory));

            _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                IRabbitMqHost host = x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
                {
                    h.Username("samplecourier");
                    h.Password("samplecourier");
                });

                x.ReceiveEndpoint(host, "routing_slip_metrics", e =>
                {
                    e.PrefetchCount = 100;
                    e.UseRetry(Retry.None);
                    e.Consumer(() => new RoutingSlipMetricsConsumer(_metrics));
                });

                x.ReceiveEndpoint(host, "routing_slip_activity_metrics", e =>
                {
                    e.PrefetchCount = 100;
                    e.UseRetry(Retry.None);
                    e.Consumer(() => new RoutingSlipActivityConsumer(_activityMetrics, "Validate"));
                });

                x.ReceiveEndpoint(host, "routing_slip_state", e =>
                {
                    e.PrefetchCount = 8;
                    e.UseConcurrencyLimit(1);
                    e.StateMachineSaga(_machine, _repository.Value);
                });
            });

            _log.Info("Starting bus...");

            _busControl.StartAsync().Wait();

            return(true);
        }
示例#3
0
        public bool Start(HostControl hostControl)
        {
            _log.Info("Creating bus...");

            _metrics         = new RoutingSlipMetrics("Routing Slip");
            _activityMetrics = new RoutingSlipMetrics("Validate Activity");

            _machine        = new RoutingSlipStateMachine();
            _provider       = new SQLiteSessionFactoryProvider(false, typeof(RoutingSlipStateSagaMap));
            _sessionFactory = _provider.GetSessionFactory();

            _repository = new NHibernateSagaRepository <RoutingSlipState>(_sessionFactory);

            _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                IRabbitMqHost host = x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                x.ReceiveEndpoint(host, "routing_slip_metrics", e =>
                {
                    e.PrefetchCount = 100;
                    e.UseRetry(r => r.None());
                    e.Consumer(() => new RoutingSlipMetricsConsumer(_metrics));
                });

                x.ReceiveEndpoint(host, "routing_slip_activity_metrics", e =>
                {
                    e.PrefetchCount = 100;
                    e.UseRetry(r => r.None());
                    e.Consumer(() => new RoutingSlipActivityConsumer(_activityMetrics, "Validate"));
                });

                x.ReceiveEndpoint(host, "routing_slip_state", e =>
                {
                    e.PrefetchCount = 8;
                    e.UseConcurrencyLimit(1);
                    e.StateMachineSaga(_machine, _repository);
                });
            });

            _log.Info("Starting bus...");

            TaskUtil.Await(() => _busControl.StartAsync());

            return(true);
        }
示例#4
0
        public bool Start(HostControl hostControl)
        {
            _log.Info("Creating bus...");

            _metrics = new RoutingSlipMetrics("Routing Slip");
            _activityMetrics = new RoutingSlipMetrics("Validate Activity");

            _machine = new RoutingSlipStateMachine();
            _provider = new SQLiteSessionFactoryProvider(false, typeof(RoutingSlipStateSagaMap));
            _sessionFactory = _provider.GetSessionFactory();

            _repository = new NHibernateSagaRepository<RoutingSlipState>(_sessionFactory);

            _busControl = Bus.Factory.CreateUsingRabbitMq(x =>
            {
                IRabbitMqHost host = x.Host(new Uri(ConfigurationManager.AppSettings["RabbitMQHost"]), h =>
                {
                    h.Username("guest");
                    h.Password("guest");
                });

                x.ReceiveEndpoint(host, "routing_slip_metrics", e =>
                {
                    e.PrefetchCount = 100;
                    e.UseRetry(Retry.None);
                    e.Consumer(() => new RoutingSlipMetricsConsumer(_metrics));
                });

                x.ReceiveEndpoint(host, "routing_slip_activity_metrics", e =>
                {
                    e.PrefetchCount = 100;
                    e.UseRetry(Retry.None);
                    e.Consumer(() => new RoutingSlipActivityConsumer(_activityMetrics, "Validate"));
                });

                x.ReceiveEndpoint(host, "routing_slip_state", e =>
                {
                    e.PrefetchCount = 8;
                    e.UseConcurrencyLimit(1);
                    e.StateMachineSaga(_machine, _repository);
                });
            });

            _log.Info("Starting bus...");

            _busHandle = _busControl.Start();

            return true;
        }
示例#5
0
 public RoutingSlipActivityConsumer(RoutingSlipMetrics metrics, string activityName)
 {
     this.metrics      = metrics;
     this.activityName = activityName;
 }
 public RoutingSlipMetricsConsumer(RoutingSlipMetrics metrics)
 {
     _metrics = metrics;
 }
 public RoutingSlipActivityConsumer(RoutingSlipMetrics metrics, string activityName)
 {
     _metrics      = metrics;
     _activityName = activityName;
 }