Skip to content

Instantly share code, notes, and snippets.

@alexjamesbrown
Created February 23, 2019 22:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexjamesbrown/1001f9eb349c0b2c53d7e1688cf0947a to your computer and use it in GitHub Desktop.
Save alexjamesbrown/1001f9eb349c0b2c53d7e1688cf0947a to your computer and use it in GitHub Desktop.
Try deadletter message on exception
[FunctionName("TopicProcessor")]
public static async Task Run(
[ServiceBusTrigger("%topic-name%", "%subscription-name%", AccessRights.Manage, Connection = "connection")] BrokeredMessage msg,
ILogger log)
{
var thing = msg.GetBody<Thing>();
var apiClient = new ApiClient();
try {
await apiClient.PostAsync(thing);
}
catch (BadRequestException) {
await msg.DeadLetterAsync("a-reason-code", "An error description");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment