Adding retry logic to your Sitecore xConnect client operations
Have you ever had an issue where an xConnect operation such as updating a contact facet has failed? Why not add some fault tolerance? I’ll show you how!
Example without retry logic
Let’s look at some code of a simple contact save that we might be doing without retry logic:
Add the XdbRequestPerformer
First we’ll add some magic. It provides some exception handling and retry logic which will retry the operation up to 5 times before giving up.
Updating the example to use the retry code
With just a few lines of code you can change it to use the XdbRequestPerformer:
And that’s it!
Another alternative
You could also use Polly to give much the same, with also only a few lines of code. However I think in this particular example it’s going to be easier to use the XdbRequestPerformer which has some additional smarts around batch operations where some operations succeeded and some failed.