Esempio n. 1
0
        public static void Main(string[] args)
        {
            var    qName  = "sachin_sqs";
            var    sqsUrl = "https://sqs.us-east-1.amazonaws.com";
            string sQueue = $"{sqsUrl}/315363577005/{qName}";
            var    awsSqsConfiguration = new AwsSqsConfiguration
            {
                AmazonSQSConfig = new AmazonSQSConfig()
                {
                    ServiceURL = sqsUrl
                },
                QueueURL = sQueue
            };
            var message = new TenantActionMessage()
            {
                TenantId   = Guid.NewGuid(),
                TenantName = "Test Action"
            };
            var awsSqsClient = new AwsSqsClient(awsSqsConfiguration);

            awsSqsClient.SendMessage(message);
            var receiptHandles = awsSqsClient.ReceiveMessage();

            receiptHandles.ForEach(receiptHandle => awsSqsClient.DeleteMessage(receiptHandle));
            // Console.Write(GetServiceOutput());
            Console.Read();
        }
 public void SendMessage(TenantActionMessage message)
 {
     try
     {
         var sendMessageRequest = new SendMessageRequest();
         sendMessageRequest.QueueUrl    = awsSqsConfiguration.QueueURL;
         sendMessageRequest.MessageBody = JsonConvert.SerializeObject(message);
         var sendMessageResponse = amazonSQSClient.SendMessage(sendMessageRequest);
         Console.WriteLine($"Send message successful : " + sendMessageResponse.ToString());
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error: " + ex.ToString());
     }
 }