1

According to the documentation, you can retry operations by registering them to the client again. I'm doing this on Sitecore 9.0.2.

https://doc.sitecore.com/developers/90/sitecore-experience-platform/en/handling-exceptions.html

In the following example, an operation is retried after xConnect returned a XdbUnavailableException, indicating that the xConnect service was unavailable:

catch (XdbUnavailableException ex) {
    // Get any operations that failed
    var operations = ex.GetOperations(client)
        .Where(x => x.Status == XdbOperationStatus.Failed);

    foreach (var ops in operations)
    {
        client.RegisterOperation(ops);
    }

    client.SubmitAsync();
}

Unfortunately, the code example on the documentation does not work. XdbUnavailableException does not contain a GetOperations method.

What should be implemented on an XdbUnavailableException?

1 Answer 1

1

Good catch. Documentation indeed is misleading. You should use XdbExecutionException which has information about failed operations, hence you can use the client to retry them.

catch (XdbExecutionException ex) {
    // Get any operations that failed
    var operations = ex.GetOperations(client)
        .Where(x => x.Status == XdbOperationStatus.Failed);

    foreach (var ops in operations)
    {
        client.RegisterOperation(ops);
    }

    client.SubmitAsync();
}
//catch all other exceptions and retry
catch (Exception)
{
    client.DirectOperations
        .Where(o => o.Status == XdbOperationStatus.Failed)
        .ForEach(op => client.RegisterOperation(op));

    client.SubmitAsync();
}
2
  • So when an XdbUnavailableException occurs, there is no way to retry the operations?
    – Koen Heye
    Mar 12, 2019 at 7:25
  • @KoenHeye, it should be possible by checking status of each operation executed by xConnect client. I have updated the answer.
    – grg
    Mar 12, 2019 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.