Skip to content

Instantly share code, notes, and snippets.

@darbio
Last active January 4, 2016 02:28
Show Gist options
  • Save darbio/4cf5f22ec70dc5a793f3 to your computer and use it in GitHub Desktop.
Save darbio/4cf5f22ec70dc5a793f3 to your computer and use it in GitHub Desktop.
string queueUrl = "YOUR_QUEUE_URL";
using (var client = new Amazon.SQS.AmazonSQSClient(Amazon.RegionEndpoint.APSoutheast2))
{
while (true)
{
// Get the messages
var response = client.ReceiveMessage(queueUrl);
// Check our response
if (response.Messages.Count > 0)
{
for (int i = 0; i < response.Messages.Count; i++)
{
// Send an email
Console.WriteLine("Sending email");
// Delete our message so that it doesn't get handled again
var receiptHandle = response.Messages[i].ReceiptHandle;
client.DeleteMessage(queueUrl, receiptHandle);
}
}
}
}
string queueUrl = "YOUR_QUEUE_URL";
using (var client = new Amazon.SQS.AmazonSQSClient(Amazon.RegionEndpoint.APSoutheast2))
{
while (true)
{
// Get the messages
var response = client.ReceiveMessage(queueUrl);
// Check our response
if (response.Messages.Count > 0)
{
for (int i = 0; i < response.Messages.Count; i++)
{
// Send an email
Console.WriteLine("Sending SMS");
// Delete our message so that it doesn't get handled again
var receiptHandle = response.Messages[i].ReceiptHandle;
client.DeleteMessage(queueUrl, receiptHandle);
}
}
}
}
string queueUrl = "YOUR_QUEUE_URL";
using (var client = new Amazon.SQS.AmazonSQSClient(Amazon.RegionEndpoint.APSoutheast2))
{
while (true)
{
// Get the messages
var response = client.ReceiveMessage(queueUrl);
// Check our response
if (response.Messages.Count > 0)
{
for (int i = 0; i < response.Messages.Count; i++)
{
// Send an email
Console.WriteLine("Updating Cache");
// Delete our message so that it doesn't get handled again
var receiptHandle = response.Messages[i].ReceiptHandle;
client.DeleteMessage(queueUrl, receiptHandle);
}
}
}
}
string INCIDENT_CREATED_ARN = "arn:aws:sns:ap-southeast-2:835265634988:INCIDENT_CREATED";
string INCIDENT_UPDATED_ARN = "arn:aws:sns:ap-southeast-2:835265634988:INCIDENT_UPDATED";
using (var client = new Amazon.SimpleNotificationService.AmazonSimpleNotificationServiceClient(Amazon.RegionEndpoint.APSoutheast2))
{
while (true)
{
Console.WriteLine("Press 1 to create a new incident, or 2 to update an existing incident.");
var key = Console.ReadKey();
if (key.KeyChar == '1')
{
Console.WriteLine("Creating incident.");
client.Publish(INCIDENT_CREATED_ARN, "Incident created.");
}
else if (key.KeyChar == '2')
{
Console.WriteLine("Updating incident");
client.Publish(INCIDENT_UPDATED_ARN, "Incident updated.");
}
else
{
Console.WriteLine("Unrecognised action.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment