using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Amazon.SimpleNotificationService; using Newtonsoft.Json; namespace sns_load_test { class Program { //Change this to control what SNS topic you are publishing to const string TopicArn = "arn:aws:sns:ap-southeast-2:xxxxxxxxxxxxxxxxxxxx"; //Change this to control how many messages to send in the load test const int NumberOfMessagesToSend = 100; static void Main(string[] args) { Run().Wait(); } static async Task Run() { List serializedMessages = new List(); for (int i = 0; i < NumberOfMessagesToSend; i++) { //Customise the content of your SNS messages as need be here var message = new { Property = "Hello World!" }; serializedMessages.Add(JsonConvert.SerializeObject(message)); } var snsClient = new AmazonSimpleNotificationServiceClient(Amazon.RegionEndpoint.APSoutheast2); IEnumerable tasks = serializedMessages.Select(async serializedMessage => { try { await snsClient.PublishAsync(TopicArn, serializedMessage); } catch (Exception ex) { Console.WriteLine(ex.Message); } }); await Task.WhenAll(tasks); Console.WriteLine("Done!"); } } }