예제 #1
0
        private async Task SendMessage(string queueName, string messageBody, ILambdaContext context)
        {
            try
            {
                var response = await SQSClient.GetQueueUrlAsync(queueName);

                await SQSClient.SendMessageAsync(response.QueueUrl, messageBody);
            }
            catch (Exception e)
            {
                context.Logger.LogLine("Send Message Error" + e.Message + " and " + e.InnerException);
            }
            await Task.CompletedTask;
        }
        async Task <SendMessageResponse> PublishMessage()
        {
            var message = ExecutedCount.ToString();
            var result  = await SQSClient.SendMessageAsync(new SendMessageRequest()
            {
                QueueUrl          = Option.QueueUrl,
                MessageBody       = message,
                MessageAttributes = new Dictionary <string, MessageAttributeValue>()
                {
                    { "generatedTs", new MessageAttributeValue()
                      {
                          DataType = "String", StringValue = GeneratedTs.ToString("s")
                      } },
                    { "generatedId", new MessageAttributeValue()
                      {
                          DataType = "String", StringValue = GeneratedId.ToString()
                      } }
                }
            });

            return(result);
        }