예제 #1
0
        private string AgentArnToSqsQueueUrl(string agentArn)
        {
            _logger.Trace("Beginning AgentArnToSqsQueueUrl");
            try
            {
                if (_numSqsQueues == 1)
                {
                    return(_sqsQueueUrls[0]);
                }

                using (var algorithm = SHA256.Create())
                {
                    var hash = algorithm.ComputeHash(Encoding.UTF8.GetBytes(agentArn));
                    var i    = BitConverter.ToInt64(hash) % _numSqsQueues;
                    if (i < 0)
                    {
                        i += _numSqsQueues;
                    }
                    _logger.Debug($"AgentARN: {agentArn} SQS Queue index: {i}");
                    return(_sqsQueueUrls[i]);
                }
            }
            finally
            {
                _logger.Trace("Ending AgentArnToSqsQueueUrl");
            }
        }
        public async Task SendMessageToQueue(string recordData)
        {
            _logger.Trace("Beginning SendMessageToQueue");

            SendMessageRequest sendMessageRequest = new SendMessageRequest
            {
                QueueUrl       = _sqsQueueUrl,
                MessageBody    = recordData,
                MessageGroupId = _sqsQueueMessageGroupId
            };//NOTE:  Enable ContentBasedDeduplication for particular SQSSqueue since not sending MessageDeduplicationId which could use recordData's Event Id

            var sendMessageResponse = await _sqsClient.SendMessageAsync(sendMessageRequest);

            _logger.Debug($"Message sent to queue {sendMessageResponse.MessageId}");

            _logger.Trace("Ending SendMessageToQueue");
        }
예제 #3
0
        public async Task AspectKinesisHandler(KinesisEvent kinesisEvent, ILambdaContext context)
        {
            if (_logger == null)
            {
                _logger = new AspectAwsLambdaLogger.AspectAwsLambdaLogger(context.Logger);  //NOTE: Needed for Test or if using CloudWatch and not using NLog->CloudWatch setup in constructor
            }
            if (_sqsFacade == null)
            {
                _sqsFacade = new AwsSqsFacade(_logger); //NOTE: Needed for Test or if using CloudWatch and not using NLog->CloudWatch setup in constructor
            }
            _logger.Debug($"DynamoDbTableName: {_dynamoDbTableName}");
            _logger.Trace("Beginning AspectKinesisHandler");

            _logger.Info($"Record Count: {kinesisEvent.Records.Count}");

            bool writeEventsToQueue = Convert.ToBoolean(Environment.GetEnvironmentVariable(WRITE_EVENTS_TO_QUEUE_ENVIRONMENT_VARIABLE_LOOKUP));

            _logger.Debug($"WriteEventsToQueue: {writeEventsToQueue}");

            foreach (var record in kinesisEvent.Records)
            {
                await ProcessEventRecord(record, writeEventsToQueue);
            }

            _logger.Trace("Ending AspectKinesisHandler");
        }
        public async Task AspectKinesisHandler(KinesisEvent kinesisEvent, ILambdaContext context)
        {
            if (_logger == null)
            {
                _logger = new AspectAwsLambdaLogger.AspectAwsLambdaLogger(context.Logger);  //NOTE: Needed for Test or if using CloudWatch and not using NLog->CloudWatch setup in constructor
            }
            if (_sqsFacade == null)
            {
                _sqsFacade = new AwsSqsFacade(_logger); //NOTE: Needed for Test or if using CloudWatch and not using NLog->CloudWatch setup in constructor
            }
            _logger.Debug($"DynamoDbTableName: {_dynamoDbTableName}");
            _logger.Trace("Beginning AspectKinesisHandler");

            _logger.Info($"Record Count: {kinesisEvent.Records.Count}");

            var writeEventsToQueue = await ReadWriteEventsToQueueFlag();

            _logger.Debug($"WriteEventsToQueue: {writeEventsToQueue}");

            foreach (var record in kinesisEvent.Records)
            {
                await ProcessEventRecord(record, writeEventsToQueue);
            }

            _logger.Trace("Ending AspectKinesisHandler");
        }