If the error occured due to a configuration issue at the subscribed endpoint, such as the endpoint being deleted, Event Grid will either dead-letter the event or discard it if dead-lettering isn't configured, as retries won't resolve the issue.
Event Grid attempts to remove events from the retry queue within 3 minutes if the endpoint responds promptly, but duplicate events may still occur.
To mitigate this, it's essential to implement safeguards in the event handler to prevent processing duplicate events. For instance, when utilizing the service bus queue event handler:
- This can be accomplished by configuring Custom delivery properties in the event subscription to map the event's ID to the MessageId header property of the service bus queue message.
- When multiple events with the same
MessageId
are received, the Service Bus Queue will automatically discard the duplicate messages.
Since Event Grid doesn't ensure event delivery order, subscribers should be prepared to receive events out of sequence.
- Provision resources in Azure:
- terraform init
- terraform plan -out main.tfplan
- terraform apply main.tfplan
- pip install -r requiremets.txt
- az login --use-device-code
- python send_and_receive_events.py
Note: change to requires_duplicate_detection = false
in the resource azurerm_servicebus_queue
in main.tf
and re-run
- terraform plan -out main.tfplan
- terraform apply main.tfplan
- repeat the test to see
assertion
fails when two messages are received.
- terraform plan -destroy -out main.destroy.tfplan
- terraform apply main.destroy.tfplan