Adding retry logic to your Sitecore xConnect client operations

Mark Gibbons
1 min readMay 10, 2019

--

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.

--

--

Mark Gibbons
Mark Gibbons

Written by Mark Gibbons

Technical Architect @ Aceik | Sitecore Technology MVP 2020 - 2024 with a love for all things #Sitecore / Twitter twitter.com/markgibbons25

No responses yet