Пример #1
0
        public static void Main()
        {
            var locationsFetcher = new LocationsFetcher(S3Client);
            var locations        = locationsFetcher.GetLocations(BucketName, KeyName);
            var locationIds      = locations.Select(l => l.Id).ToList();
            var processor        = new MessageProcessor(locationIds);



            using (var queue = new SubscribedQueue(SqsClient, SnsClient, TopicArn))
            {
                var timeNow = DateTime.Now;
                var endTime = timeNow.AddSeconds(RunTime);
                Console.WriteLine("Processing messages....");

                while (DateTime.Now < endTime)
                {
                    var messageResponse = processor.CollectMessages(queue, SqsClient);
                    processor.ProcessMessagesFromResponse(messageResponse);
                }

                Console.WriteLine("Readings with removals: " + processor.Readings.Count);
                Console.WriteLine("finished processing messages.");
            }
        }
Пример #2
0
        static void Main()
        {
            // var awsCredentials = new BasicAWSCredentials(Environment.GetEnvironmentVariable("AWS_ACCESS_KEY"), Environment.GetEnvironmentVariable("AWS_SECRET_KEY"));
            var locationFetcher = new LocationsFetcher();
            var sqsClient       = new AmazonSQSClient(RegionEndpoint.EUWest2);
            var snsClient       = new AmazonSimpleNotificationServiceClient(RegionEndpoint.EUWest2);
            var sqsService      = new SqsService(sqsClient);
            var snsService      = new SnsService(snsClient, sqsClient);
            var locations       = locationFetcher.LocationListMaker();
            var messageManager  = new MessageManager(sqsService, new MessageParser(), new LocationChecker(locations));


            var locationList = locationFetcher.LocationListMaker();

            foreach (var location in locationList)
            {
                Console.WriteLine($"Location ID:{location.Id} has the location (x:{location.x}, y:{location.y}).");
            }
            using (var queue = new SubscribedQueue(sqsService, snsService))
            {
                var endTime = DateTime.Now.AddMinutes(1);
                while (DateTime.Now < endTime)
                {
                    messageManager.ProcessMessages(queue.QueueUrl);
                }
            }
            Console.WriteLine("finished.");
        }