Пример #1
0
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc()
     .AddNewtonsoftJson(options => options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore);
     services.Configure <AppConfig>(Configuration);
     services.AddLogging(x => x.AddFilter("Microsoft", LogLevel.Warning));
     services.AddSingleton <IAmazonSQS>(x => SqsClientFactory.CreateClient(_appConfig));
     services.AddSingleton <ISqsClient, SqsClient>();
     services.AddHealthChecks()
     .AddCheck <SqsHealthCheck>("SQS Health Check");
 }
Пример #2
0
        static void Main(string[] args)
        {
            var _client = SqsClientFactory.GetClient();

            try
            {
                var response = _client.SendMessage(SqsConfigHelper.Config.QueueUrl,
                                                   $"Hello {DateTime.Now}");

                Console.WriteLine(response.HttpStatusCode);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadKey();
        }
Пример #3
0
        static void Main(string[] args)
        {
            var _client = SqsClientFactory.GetClient();

            try
            {
                var request = new ReceiveMessageRequest(SqsConfigHelper.Config.QueueUrl)
                {
                    MaxNumberOfMessages = 10, WaitTimeSeconds = 20
                };
                var response = _client.ReceiveMessage(request);
                response.Messages.ForEach(x => Console.WriteLine(x.Body));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            Console.ReadKey();
        }
Пример #4
0
 public void ConfigureServices(IServiceCollection services)
 {
     services.AddMvc()
     .AddNewtonsoftJson(options => options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore);
     services.Configure <AppConfig>(Configuration);
     services.AddLogging(x => x.AddFilter("Microsoft", LogLevel.Warning));
     //#if (AddSqsPublisher || AddSqsConsumer)
     services.AddSingleton <IAmazonSQS>(x => SqsClientFactory.CreateClient(_appConfig.AwsSettings));
     services.AddSingleton <ISqsClient, SqsClient>();
     //#endif
     //#if (AddSqsConsumer)
     services.AddSingleton <ISqsConsumerService, SqsConsumerService>();
     services.AddScoped <IMessageProcessor, ActorMessageProcessor>();
     services.AddScoped <IMessageProcessor, MovieMessageProcessor>();
     //#endif
     //#if (AddHealthChecks)
     services.AddHealthChecks()
     //#if (AddSqsPublisher || AddSqsConsumer)
     .AddCheck <SqsHealthCheck>("SQS Health Check")
     //#endif
     .AddCheck <VersionHealthCheck>("Version Health Check");
     //#endif
 }
Пример #5
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc()
            .AddNewtonsoftJson(options => options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore);
            services.Configure <AppConfig>(Configuration);
            services.AddLogging(x => x.AddFilter("Microsoft", LogLevel.Warning));

            services.AddSingleton <IAmazonSQS>(x => SqsClientFactory.CreateClient(_appConfig));
            services.AddSingleton <ISqsClient, SqsClient>();
            services.AddSingleton <ISqsConsumerService, SqsConsumerService>();

            services.AddSingleton <IAmazonDynamoDB>(x => DynamoDbClientFactory.CreateClient(_appConfig));
            services.AddSingleton <IDatabaseClient, DatabaseClient>();
            services.AddSingleton <IDynamoDBContext, DynamoDBContext>();
            services.AddSingleton <IActorsRepository, ActorsRepository>();
            services.AddSingleton <IMoviesRepository, MoviesRepository>();

            services.AddScoped <IMessageProcessor, ActorMessageProcessor>();
            services.AddScoped <IMessageProcessor, MovieMessageProcessor>();
            services.AddScoped <IMessageProcessor, LogEntryMessageProcessor>();

            services.AddHealthChecks()
            .AddCheck <SqsHealthCheck>("SQS Health Check");
        }