private async Task RunAsync(CancellationToken cancellationToken) { var queueClient = StorageAccount.CreateCloudQueueClient(); var queue = queueClient.GetQueueReference("email-queue"); var mailgunVendor = new MailgunSender.Sender(); while (!cancellationToken.IsCancellationRequested) { var queueMsg = await queue.GetMessageAsync(cancellationToken); if (queueMsg == null) { continue; } var isProcessed = await MessageHandler.ProcessMessage(queueMsg, mailgunVendor, cancellationToken); // if the vendor's api call failed, move next, and the message will be dequeued and // picked up again after its visibilty time of 30 sec. expires if (isProcessed) { // otherwise delete the message from the queue await queue.DeleteMessageAsync(queueMsg, cancellationToken); } } }
public async Task TestSendEmailWithMailgun() { var sender = new MailgunSender.Sender(); var isSent = await MainSenderTests.TestSendEmail(sender); Assert.IsTrue(isSent); }