Esempio n. 1
0
        public async Task StartAsync()
        {
            var repository = new MongoDbSagaRepository <GameSaga>(mongoDbConfig.Endpoint, mongoDbConfig.Database, Collections.GameSagas);

            busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                var rabbitMqHost = cfg.Host(new Uri(rabbitMqConfig.Endpoint), host =>
                {
                    host.Username(rabbitMqConfig.Username);
                    host.Password(rabbitMqConfig.Password);
                });

                cfg.ReceiveEndpoint(rabbitMqHost, rabbitMqConfig.GetQueueName(Queues.GameSaga), e =>
                {
                    // Specify the maximum number of concurrent messages that are consumed
                    e.PrefetchCount = (ushort)Environment.ProcessorCount;
                    // Defer publish of messages until saga is persisted
                    // Required for PrefetchCount > 1
                    // https://stackoverflow.com/questions/38716143/masstransit-saga-running-with-prefetch-1
                    e.UseInMemoryOutbox();
                    e.StateMachineSaga(stateMachine, repository);
                });

                // In-memory quartz do not provide persistence
                // For production use separate quartz service or rabbitmq scheduling plugin
                cfg.UseInMemoryScheduler();
            });

            logger.LogInformation("Starting MT bus");
            await busControl.StartAsync();

            logger.LogInformation("Started MT bus");
        }
Esempio n. 2
0
        public async Task StartAsync()
        {
            busControl = Bus.Factory.CreateUsingRabbitMq(cfg =>
            {
                var host = cfg.Host(new Uri(rmqConfig.Endpoint), h =>
                {
                    h.Username(rmqConfig.Username);
                    h.Password(rmqConfig.Password);
                });

                cfg.ReceiveEndpoint(host, rmqConfig.GetQueueName(Queues.Dictionary), ep =>
                {
                    ep.PrefetchCount = (ushort)Environment.ProcessorCount;

                    ep.Consumer <SelectWordConsumer>(provider);
                });
            });

            await busControl.StartAsync();
        }