Skip to content

Instantly share code, notes, and snippets.

@scott-kloud
Created May 22, 2017 06:03
Show Gist options
  • Save scott-kloud/3a1f05dc931793812a93090bacb8b7df to your computer and use it in GitHub Desktop.
Save scott-kloud/3a1f05dc931793812a93090bacb8b7df to your computer and use it in GitHub Desktop.
// Load our retry handler helper
#load "retryhandler.csx"
#r "Microsoft.ServiceBus"
using Microsoft.ServiceBus.Messaging;
using System;
using System.Threading.Tasks;
public static void Run(BrokeredMessage mySbMsg, TraceWriter log)
{
log.Info($"C# ServiceBus topic trigger function received message id: {mySbMsg.MessageId} Retry attempt: {mySbMsg.DeliveryCount}");
try
{
// Mock a business processing error
throw new ApplicationException("Customer code is invalid. Please fix and resend");
// Mock a transport protocol error
//throw new TimeoutException("Service unavailable");
}
catch (Exception ex)
{
log.Info($"Calling retry handler...");
// Manage retries using our message retry handler
RetryHandler(mySbMsg, ex, log);
}
log.Info($"C# ServiceBus topic trigger function processed message id: {mySbMsg.MessageId}");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment