예제 #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            var awsConfig      = Configuration.GetSection("AWS");
            var sqsConfigParam = new SqsConfigParam
            {
                ServiceUrl = awsConfig["serviceURL"],
                ReceiveMessageWaitTimeSeconds = int.Parse(awsConfig["receiveMessageWaitTimeSeconds"]),
                VisibilityTimeout             = int.Parse(awsConfig["visibilityTimeout"])
            };

            services.AddSingleton(config => sqsConfigParam);

            services.AddSingleton(client =>
            {
                var c = new AmazonSQSConfig {
                    ServiceURL = sqsConfigParam.ServiceUrl
                };
                return(new AmazonSQSClient(c));
            }
                                  );
        }
 public SqsController(ILogger <SqsController> logger, SqsConfigParam sqsConfigParam, AmazonSQSClient client)
 {
     _sqsConfigParam = sqsConfigParam;
     _logger         = logger;
     _client         = client;
 }