Пример #1
0
        private static IBusControl ConfigureReadBus()
        {
            var expertTaggingStateMachine = new SampleSaga();

            SagaDbContextFactory sagaDbContextFactory =
                () => new SagaDbContext <SampleSagaState, SampleSagaMapping>("default");

            var stateMachineRepository = new EntityFrameworkSagaRepository <SampleSagaState>(sagaDbContextFactory);

            var busControl = Bus.Factory.CreateUsingAzureServiceBus(cfg =>
            {
                cfg.UseNLog();

                IServiceBusHost host = cfg.Host(ConfigurationManager.AppSettings["azureServiceBus:ConnectionString"],
                                                hcfg => { });

                cfg.ReceiveEndpoint(host, "sample_queue", ecfg =>
                {
                    ecfg.StateMachineSaga(expertTaggingStateMachine, stateMachineRepository);
                });
            });

            var observer = new ReceiveObserver(true);

            busControl.ConnectReceiveObserver(observer);

            return(busControl);
        }
Пример #2
0
        private static IBusControl ConfigureWriteBus()
        {
            var busControl = Bus.Factory.CreateUsingAzureServiceBus(cfg =>
            {
                cfg.UseNLog();

                cfg.Host(ConfigurationManager.AppSettings["azureServiceBus:ConnectionString"],
                         hcfg => { });
            });

            var observer = new ReceiveObserver(true);

            busControl.ConnectReceiveObserver(observer);

            return(busControl);
        }