Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. foreach (EventData eventData in events)
  2. {
  3. try
  4. {
  5. string messageBody = Encoding.UTF8.GetString(eventData.Body.Array, eventData.Body.Offset, eventData.Body.Count);
  6.  
  7. // Replace these two lines with your processing logic.
  8. log.LogInformation($"C# Event Hub trigger function processed a message: {messageBody}");
  9. await Task.Yield();
  10. }
  11. catch (Exception e)
  12. {
  13. // We need to keep processing the rest of the batch - capture this exception and continue.
  14. // Also, consider capturing details of the message that failed processing so it can be processed again later.
  15. exceptions.Add(e);
  16. }
  17. }
  18.  
  19. // Once processing of the batch is complete, if any messages in the batch failed processing throw an exception so that there is a record of the failure.
  20.  
  21. if (exceptions.Count > 1)
  22. throw new AggregateException(exceptions);
  23.  
  24. if (exceptions.Count == 1)
  25. throw exceptions.Single();
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement