Ejemplo n.º 1
0
        public async Task <IActionResult> Post([FromBody] LambdaMessage message)
        {
            var json     = JsonConvert.SerializeObject(message);
            var topicArn = Configuration[Constants.Keys.TopicArn];
            var result   = await SNSClient.PublishAsync(topicArn, json);

            Logger.LogInformation($"Published SNS Topic. Message Id: {result.MessageId}");
            return(StatusCode((int)result.HttpStatusCode, result.MessageId));
        }
Ejemplo n.º 2
0
 public void PublishMessageToTopic(string subject, string message, string topicArn)
 {
     SNSClient.PublishAsync(new PublishRequest()
     {
         Subject  = subject,
         Message  = message,
         TopicArn = topicArn
     });
 }
Ejemplo n.º 3
0
        public async Task FunctionHandler(object input, ILambdaContext context)
        {
            context.Logger.LogLine($"Message received: {Environment.NewLine}{input}");

            try
            {
                await _snsClient.PublishAsync(new GenericMessage <object>(input));

                context.Logger.LogLine($"Message sent");
            }
            catch (Exception ex)
            {
                context.Logger.LogLine($"Error occured:{Environment.NewLine}{ex.Message}");
                throw;
            }
        }
Ejemplo n.º 4
0
        private async Task <bool> NotifyStatus(Guid id, ILambdaLogger logger)
        {
            try
            {
                var topic = await SNSClient.FindTopicAsync(Config.GetSection("SimpleNotificationServiceTopic").Value);

                if (topic != null)
                {
                    await SNSClient.PublishAsync(topic.TopicArn, $"Batch job will be scheduled for {id}").ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                logger.LogLine("error on sending status");
                logger.LogLine(ex.Message);
                logger.LogLine(ex.StackTrace);
                throw;
            }

            return(true);
        }