Beispiel #1
0
        public void CreateBus(IServiceCollectionBusConfigurator busConfigurator, IStartupBusConfigurator configurator)
        {
            if (!configurator.HasSchedulerEndpoint)
            {
                busConfigurator.AddServiceBusMessageScheduler();
            }

            busConfigurator.UsingAzureServiceBus((context, cfg) =>
            {
                var options = context.GetRequiredService <IOptions <ServiceBusOptions> >().Value;
                if (string.IsNullOrWhiteSpace(options.ConnectionString))
                {
                    throw new ConfigurationException("The Azure Service Bus ConnectionString must not be empty.");
                }

                cfg.Host(options.ConnectionString);

                if (!configurator.TryConfigureQuartz(cfg))
                {
                    Log.Information("Configuring Azure Service Bus Message Scheduler (enqueue time)");
                    cfg.UseServiceBusMessageScheduler();
                }

                configurator.ConfigureBus(cfg, context);
            });
        }
Beispiel #2
0
        protected override void ConfigureMassTransit(IServiceCollectionBusConfigurator configurator)
        {
            configurator.AddActivitiesFromNamespaceContaining <GrillBurgerActivity>();

            configurator.AddRequestClient <OrderBurger>();
            configurator.AddRequestClient <OrderOnionRings>();
        }
        protected override void ConfigureMassTransit(IServiceCollectionBusConfigurator configurator)
        {
            configurator.AddConsumer <CookFryConsumer>();

            configurator.AddFuture <FryFuture>();
            configurator.AddFuture <CalculateFuture>();
        }
Beispiel #4
0
 /// <summary>
 /// Configure message consumers.
 /// </summary>
 /// <param name="configurator">The configurator.</param>
 public void RegisterConsumers(IServiceCollectionBusConfigurator configurator)
 {
     configurator.AddConsumer <DownloadFileConsumer>();
     configurator.AddConsumer <UploadBase64ImageConsumer>();
     configurator.AddConsumer <UploadFileConsumer>();
     configurator.AddConsumer <DeleteFileConsumer>();
 }
Beispiel #5
0
        protected override void ConfigureMassTransit(IServiceCollectionBusConfigurator configurator)
        {
            configurator.AddConsumer <PourShakeConsumer>();
            configurator.AddConsumer <CookFryConsumer>();

            configurator.AddRequestClient <OrderFryShake>();
        }
Beispiel #6
0
        void CreateBus(IServiceCollectionBusConfigurator busConfigurator, IServiceProvider provider)
        {
            var platformOptions = provider.GetRequiredService <IOptions <PlatformOptions> >().Value;

            var configurator = new StartupBusConfigurator(platformOptions);

            switch (platformOptions.Transport.ToLower(CultureInfo.InvariantCulture))
            {
            case PlatformOptions.RabbitMq:
            case PlatformOptions.RMQ:
                new RabbitMqStartupBusFactory().CreateBus(busConfigurator, configurator);
                break;

            case PlatformOptions.AzureServiceBus:
            case PlatformOptions.ASB:
                new ServiceBusStartupBusFactory().CreateBus(busConfigurator, configurator);
                break;

            case PlatformOptions.ActiveMq:
            case PlatformOptions.AMQ:
                new ActiveMqStartupBusFactory().CreateBus(busConfigurator, configurator);
                break;

            case PlatformOptions.AmazonSqs:
                new AmazonSqsStartupBusFactory().CreateBus(busConfigurator, configurator);
                break;

            default:
                throw new ConfigurationException($"Unknown transport type: {platformOptions.Transport}");
            }
        }
        private static void ConfigureBus(
            this IServiceCollectionBusConfigurator busConfigurator,
            string?queueName,
            MessagingOptions options)
        {
            if (options.Transport == MessagingTransport.InMemory)
            {
                busConfigurator.AddBus(provider => Bus.Factory.CreateUsingInMemory(cfg =>
                {
                    cfg.ReceiveEndpoint(e =>
                    {
                        e.ConfigureConsumers(provider);
                    });
                }));
            }
            else
            {
                busConfigurator.AddBus(provider => Bus.Factory.CreateUsingRabbitMq(cfg =>
                {
                    cfg.Host(options.ServiceBus.Host, c =>
                    {
                        c.Username(options.ServiceBus.Username);
                        c.Password(options.ServiceBus.Password);
                    });

                    cfg.ReceiveEndpoint(queueName, e =>
                    {
                        e.ConfigureConsumers(provider);
                    });
                }));
            };
        }
Beispiel #8
0
        public void ConfigureMassTransit(IServiceCollectionBusConfigurator configurator, IServiceCollection services)
        {
            _logger.LogInformation("MassTransit Platform, Quartz Service - Configuring MassTransit");

            services.Configure <OtherOptions>(_configuration);
            services.Configure <QuartzOptions>(_configuration.GetSection("Quartz"));
            services.AddSingleton <QuartzConfiguration>();

            services.AddSingleton(provider =>
            {
                var options = provider.GetRequiredService <QuartzConfiguration>();

                return(new InMemorySchedulerOptions
                {
                    SchedulerFactory = new StdSchedulerFactory(options.Configuration),
                    QueueName = options.Queue
                });
            });
            services.AddSingleton <SchedulerBusObserver>();
            services.AddSingleton(provider => provider.GetRequiredService <SchedulerBusObserver>().Scheduler);

            services.AddSingleton <QuartzEndpointDefinition>();

            configurator.AddConsumer <ScheduleMessageConsumer>(typeof(ScheduleMessageConsumerDefinition));
            configurator.AddConsumer <CancelScheduledMessageConsumer>(typeof(CancelScheduledMessageConsumerDefinition));
        }
 public static void ConfigureAuthorizationRequestConsumers(this IServiceCollectionBusConfigurator configurator, Action <Type, Type> action)
 {
     foreach (var messageTypeConsumerTypeMapping in MessageTypeConsumerTypeMappings)
     {
         action(messageTypeConsumerTypeMapping.Key, messageTypeConsumerTypeMapping.Value);
     }
 }
Beispiel #10
0
        protected override void ConfigureMassTransit(IServiceCollectionBusConfigurator configurator)
        {
            configurator.AddActivitiesFromNamespaceContaining <GrillBurgerActivity>();

            configurator.AddFuture <BurgerFuture>();
            configurator.AddFuture <OnionRingsFuture>();
        }
 private static void AddSaga <TSaga, TSagaState>(IServiceCollectionBusConfigurator configuration, RedisCredentials redisCredentials) where TSaga : class, SagaStateMachine <TSagaState> where TSagaState : class, SagaStateMachineInstance, ISagaVersion
 {
     configuration.AddSagaStateMachine <TSaga, TSagaState>().RedisRepository(r =>
     {
         r.KeyPrefix = typeof(TSaga).Name;
         r.DatabaseConfiguration(redisCredentials.ConnectionString);
     });
 }
        protected override void ConfigureMassTransit(IServiceCollectionBusConfigurator configurator)
        {
            configurator.AddConsumer <CookFryConsumer>();
            configurator.AddConsumer <CookOnionRingsConsumer>();
            configurator.AddActivitiesFromNamespaceContaining <GrillBurgerActivity <BurgerPatty> >();

            configurator.AddFuturesFromNamespaceContaining <OrderFuture>();
        }
Beispiel #13
0
 public void ConfigureFutureSagaRepository(IServiceCollectionBusConfigurator configurator)
 {
     configurator.AddSagaRepository <FutureState>()
     .AzureTableRepository(r =>
     {
         r.ConnectionFactory(provider => provider.GetRequiredService <CloudTableClient>().GetTableReference(TableName));
     });
 }
Beispiel #14
0
 public void AddExecuteActivity(IServiceCollectionBusConfigurator serviceCollectionBusConfigurator)
 {
     foreach (var commandType in _types)
     {
         Type commandActivityType = typeof(CommandActivity <>).MakeGenericType(commandType);
         serviceCollectionBusConfigurator.AddExecuteActivity(commandActivityType, null);
     }
 }
        /// <summary>
        /// Add a saga test harness for the specified saga to the container. The saga must be added separately, including
        /// a valid saga repository.
        /// </summary>
        public static void AddSagaTestHarness <T>(this IServiceCollectionBusConfigurator configurator)
            where T : class, ISaga
        {
            var services = configurator.Collection;

            services.AddSingleton <SagaTestHarnessRegistration <T> >();
            services.AddSingleton <ISagaRepositoryDecoratorRegistration <T> >(provider => provider.GetService <SagaTestHarnessRegistration <T> >());
            services.AddSingleton <ISagaTestHarness <T>, RegistrationSagaTestHarness <T> >();
        }
Beispiel #16
0
        // 여기서는 2개의 StateMachine 이 필요.
        protected override void ConfigureMassTransit(IServiceCollectionBusConfigurator cfg)
        {
            base.ConfigureMassTransit(cfg);

            // ReservationStateMachine 에, 추가로 BookStateMachine 을 명시적으로 생성.
            cfg.AddSagaStateMachine <BookStateMachine, BookSaga>()
            .InMemoryRepository();
            cfg.AddSagaStateMachineTestHarness <BookStateMachine, BookSaga>();
        }
        protected override void ConfigureMassTransit(IServiceCollectionBusConfigurator configurator)
        {
            configurator.AddConsumer <PourShakeConsumer>();
            configurator.AddConsumer <CookFryConsumer, CookFryConsumerDefinition>();

            configurator.AddFuture <FryFuture>();
            configurator.AddFuture <ShakeFuture>();
            configurator.AddFuture <FryShakeFuture>();
        }
 public override void AddSagasAction(IServiceCollectionBusConfigurator serviceCollectionBusConfigurator)
 {
     serviceCollectionBusConfigurator.AddSagaStateMachine <CreateDocumentStateMachine, CreateDocumentState>()
     .InMemoryRepository();
     serviceCollectionBusConfigurator.AddSagaStateMachine <UpdateDocumentStateMachine, UpdateDocumentState>()
     .InMemoryRepository();
     serviceCollectionBusConfigurator.AddSagaStateMachine <DeleteDocumentStateMachine, DeleteDocumentState>()
     .InMemoryRepository();
 }
        /// <summary>
        /// Add a consumer test harness for the specified consumer to the container
        /// </summary>
        public static void AddConsumerTestHarness <T>(this IServiceCollectionBusConfigurator configurator)
            where T : class, IConsumer
        {
            var services = configurator.Collection;

            services.AddSingleton <ConsumerTestHarnessRegistration <T> >();
            services.AddSingleton <IConsumerFactoryDecoratorRegistration <T> >(provider => provider.GetService <ConsumerTestHarnessRegistration <T> >());
            services.AddSingleton <IConsumerTestHarness <T>, RegistrationConsumerTestHarness <T> >();
        }
        protected override void ConfigureMassTransit(IServiceCollectionBusConfigurator configurator)
        {
            configurator.AddSagaStateMachine <BookStateMachine, Book>()
            .InMemoryRepository();

            configurator.AddPublishMessageScheduler();

            configurator.AddSagaStateMachineTestHarness <BookStateMachine, Book>();
        }
Beispiel #21
0
 public void ConfigureMassTransit(IServiceCollectionBusConfigurator configurator, IServiceCollection services)
 {
     configurator.AddConsumersFromNamespaceContaining <AllocateInventoryConsumer>();
     configurator.AddSagaStateMachine <AllocationStateMachine, AllocationState>(typeof(AllocateStateMachineDefinition))
     .MongoDbRepository(cfg => {
         cfg.Connection   = "mongodb://mongo";
         cfg.DatabaseName = "allocations";
     });;
 }
        protected override void ConfigureMassTransit(IServiceCollectionBusConfigurator cfg)
        {
            base.ConfigureMassTransit(cfg);

            cfg
            .AddConsumer <ChargeMemberFineConsumer>()
            .Endpoint(x => x.Name = "charge-member-fine")
            ;
        }
        /// <summary>
        /// Add a saga test harness for the specified saga to the container. The saga must be added separately, including
        /// a valid saga repository.
        /// </summary>
        public static void AddSagaStateMachineTestHarness <TStateMachine, TInstance>(this IServiceCollectionBusConfigurator configurator)
            where TInstance : class, SagaStateMachineInstance
            where TStateMachine : SagaStateMachine <TInstance>
        {
            var services = configurator.Collection;

            services.AddSingleton <SagaTestHarnessRegistration <TInstance> >();
            services.AddSingleton <ISagaRepositoryDecoratorRegistration <TInstance> >(provider => provider.GetService <SagaTestHarnessRegistration <TInstance> >());
            services.AddSingleton <IStateMachineSagaTestHarness <TInstance, TStateMachine>, RegistrationStateMachineSagaTestHarness <TInstance, TStateMachine> >();
        }
 public static void AddAuthorizationRequestConsumers(this IServiceCollectionBusConfigurator configurator)
 {
     foreach (var messagesType in configurator.GetDiscoveredMessageTypes())
     {
         var consumerType = typeof(AuthorizationRequestMessageConsumer <>).MakeGenericType(messagesType);
         Log.Information("Registering consumer {ConsumerType}", consumerType);
         configurator.AddConsumer(consumerType);
         MessageTypeConsumerTypeMappings[messagesType] = consumerType;
     }
 }
Beispiel #25
0
        public void ConfigureFutureSagaRepository(IServiceCollectionBusConfigurator configurator)
        {
            configurator.AddSagaRepository <FutureState>()
            .EntityFrameworkRepository(r =>
            {
                r.ConcurrencyMode       = ConcurrencyMode.Pessimistic;
                r.LockStatementProvider = new SqlServerLockStatementProvider();

                r.ExistingDbContext <FutureSagaDbContext>();
            });
        }
 public void ConfigureMassTransit(IServiceCollectionBusConfigurator configurator, IServiceCollection services)
 {
     configurator.AddConsumersFromNamespaceContaining <AllocateInventoryConsumer>();
     configurator
     .AddSagaStateMachine <AllocationStateMachine, AllocationState>(typeof(AllocateStateMachineDefinition))
     .MongoDbRepository(r =>
     {
         r.Connection   = "mongodb://172.20.0.25:27017";  //mongodb://mongo doesnt work. Changed to docker machine ip address
         r.DatabaseName = "allocations";
     });
 }
        public void ConfigureMassTransit(IServiceCollectionBusConfigurator configurator, IServiceCollection services)
        {
            _logger.LogInformation("MassTransit Platform, Quartz Service - Configuring MassTransit");

            services.Configure <OtherOptions>(_configuration);
            services.Configure <QuartzOptions>(_configuration.GetSection("Quartz"));
            services.AddSingleton <QuartzConfiguration>();

            services.AddSingleton <QuartzEndpointDefinition>();

            configurator.AddConsumer <ScheduleMessageConsumer>(typeof(ScheduleMessageConsumerDefinition));
            configurator.AddConsumer <CancelScheduledMessageConsumer>(typeof(CancelScheduledMessageConsumerDefinition));
        }
 private static void AddWorkerConsumers(this IServiceCollectionBusConfigurator busConfigurator)
 {
     busConfigurator.AddConsumer <FaceUpdatedConsumer>();
     busConfigurator.AddConsumer <MoveMediaConsumer>();
     busConfigurator.AddConsumer <FavoriteMediaToggledConsumer>();
     busConfigurator.AddConsumer <PersonUpdatedConsumer>();
     busConfigurator.AddConsumer <ItemsAddedToAlbumConsumer>();
     busConfigurator.AddConsumer <RecycleMediaConsumer>();
     busConfigurator.AddConsumer <DeleteMediaConsumer>();
     busConfigurator.AddConsumer <UpdateMediaMetadataConsumer>();
     busConfigurator.AddConsumer <NewMediaAddedConsumer>();
     busConfigurator.AddConsumer <RescanFacesMessageConsumer>();
 }
        public void CreateBus(IServiceCollectionBusConfigurator busConfigurator, IStartupBusConfigurator configurator)
        {
            if (!configurator.HasSchedulerEndpoint)
            {
                busConfigurator.AddAmazonSqsMessageScheduler();
            }

            busConfigurator.UsingAmazonSqs((context, cfg) =>
            {
                var options = context.GetRequiredService <IOptions <AmazonSqsOptions> >().Value;
                if (string.IsNullOrWhiteSpace(options.Region))
                {
                    cfg.Host(new UriBuilder("amazonsqs://docker.localhost:4576")
                    {
                        Path = options.Scope
                    }.Uri, h =>
                    {
                        h.AccessKey("admin");
                        h.SecretKey("admin");
                        h.Config(new AmazonSimpleNotificationServiceConfig {
                            ServiceURL = "http://docker.localhost:4575"
                        });
                        h.Config(new AmazonSQSConfig {
                            ServiceURL = "http://docker.localhost:4576"
                        });
                    });
                }
                else
                {
                    cfg.Host(new UriBuilder("amazonsqs://host")
                    {
                        Host = options.Region,
                        Path = options.Scope
                    }.Uri, h =>
                    {
                        h.AccessKey(options.AccessKey);
                        h.SecretKey(options.SecretKey);
                    });
                }

                if (!configurator.TryConfigureQuartz(cfg))
                {
                    Log.Information("Configuring Amazon SQS Message Scheduler");
                    cfg.UseAmazonSqsMessageScheduler();
                }

                configurator.ConfigureBus(cfg, context);
            });
        }
 public void ConfigureMassTransit(IServiceCollectionBusConfigurator configurator, IServiceCollection services)
 {
     configurator.AddConsumersFromNamespaceContaining <AllocateInventoryConsumer>();
     configurator.AddSagaStateMachine <AllocationStateMachine, AllocationState>(typeof(AllocateStateMachineDefinition))
     .EntityFrameworkRepository(r =>
     {
         r.AddDbContext <DbContext, AllocationStateDbContext>((provider, builder) =>
         {
             builder.UseSqlServer("Server=tcp:gertjvr.database.windows.net,1433;Initial Catalog=gertjvr;Persist Security Info=False;User ID=gertjvr;Password=Works4me!;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;", m =>
             {
                 m.MigrationsAssembly(Assembly.GetExecutingAssembly().GetName().Name);
                 m.MigrationsHistoryTable($"__{nameof(AllocationStateDbContext)}");
             });
         });
     });
 }