Page 23 - MSDN Magazine, September 2018
P. 23

Topics Event Subscriptions
first attempt, the delivery schedule will back off, using the following timeline: 10 seconds, 30 seconds, 1 minute, 5 minutes, 10 minutes, 30 minutes and 1 hour. After the first one-hour attempt, each subsequent request is made once per hour until the time-to-live (TTL) is reached.
A new feature in Event Grid allows you to configure the retry policy for an event subscription by setting two possible values:
Max delivery attempts is a configurable value that sets the maximum retry attempts for an event subscription. Its default val- ue, and maximum allowed, is 30.
Event TTL is a value that corresponds to the time-to-live setting for an event. Its default value, as well as its maximum set- ting, is 1,440 minutes (24 hours).
Blob Storage Media Services Azure Subscriptions Resource Groups Event Hubs
IoT Hub Service Bus Custom Topics
Event Sources
Figure 1 Azure Event Grid Overview
same event repeatedly should produce the same result. If the ordering of events is a requirement, this should be managed on either the com- pute side (within the logic of the event handler) or by using another service such as Service Bus or Event Hubs to preserve their order.
The HTTP response that’s returned by the event handler to Event Grid will determine how it will proceed with the management of the event. The status codes 200 OK and 202 Accepted are consid- ered to be an acknowledgement of a successfully delivered event.
Any of the following failure codes are indicative of a failed delivery attempt: 400 Bad Request, 401 Unauthorized, 404 Not Found, 408 Request Timeout, 414 URI Too Long, 500 Internal Server Error, 503 Service Unavailable and 504 Gateway Timeout. Depending on the failure code, Event Grid might retry sending the event to the endpoint. I’ll dig into this in just a bit.
Retry Policies
If an acknowledgement isn’t received or an error code is returned, another attempt will be made to send the event to the endpoint. A retry policy that employs an exponential backup is then put into place to attempt a final delivery of the event before it expires. By default, an event will expire after 24 hours of unsuccessful delivery. After the
Azure Functions Logic Apps Azure Automation WebHooks Queue Storage Hybrid Connections Event Hubs
Event Handlers
Events
Subscription Events
Dead Letter Events
Either of these properties can be used to manage the retry policy at the event subscription level and can be useful when an event is interesting to you only for a short period of time, or you’re intentionally throwing an error such as
503 to protect yourself during high load.
Invalid and Dead Letter Channels
One of the primary responsibilities of a messaging service is to ensure that a message is delivered properly. However, it can’t guar- antee that the receiver of that message will handle it successfully.
In some cases, the receiver of an event might reject the message if it doesn’t meet certain expectations. This could come in the form of an invalid data type or payload, or an unauthorized message. When this happens, the message is typically moved to a designated location, often referred to as an invalid message channel.
Another common scenario is a message that’s successfully sent but can’t be processed due to an error on the receiving end. These are typ- ically the 500-level status codes that indicate a service error or service unavailability. Usually, the messaging service will retry sending these messages until a threshold is met and the message is deemed unde- liverable. A dead letter channel is used, similar to the invalid message channel, to store these messages along with any relevant metadata.
The desire in both scenarios is that there will be some utility or service that monitors the channels and will know what to do with the messages. This could surface in a scheduled report or perhaps another event-driven service, such as a Logic App, that can pick up the message and notify end users or other systems and services.
Dead Lettering with Event Grid
A highly requested feature for Azure Event Grid shortly after it was released was to provide a mechanism for capturing events that couldn’t be delivered. This feature has recently come to frui- tion with the ability to configure the retry policies and dead letter
September 2018 15
Users
Event Grid Custom Topic
Azure Function
Azure Storage
Figure 2 Dead Letter Events msdnmagazine.com


































































































   21   22   23   24   25