Skip to content

Custom retry handlers - #29

Merged
Chris Gillum (cgillum) merged 2 commits into
mainfrom
cgillum/retry-handlers
Apr 7, 2022
Merged

Custom retry handlers#29
Chris Gillum (cgillum) merged 2 commits into
mainfrom
cgillum/retry-handlers

Conversation

@cgillum

@cgillumChris Gillum (cgillum) commented Apr 7, 2022

Copy link
Copy Markdown
Member

This PR completes the retry policy feature for Java by allowing developers to implement custom retry policies using code. It's intended for use-cases where declarative retry policies aren't flexible enough.

Example syntax

TaskOptionsoptionsWithRetryHandler = TaskOptions.FromRetryHandler(retryCtx -> {
// Retries MyException or any sub-class of MyExceptionif (retryCtx.getLastFailure().isCausedBy(MyException.class)) {
returntrue;
} else {
// For any other exception type, retry up to 4 timesreturnretryCtx.getLastAttemptNumber() < 5;
} });
TaskOrchestration = ctx -> {
ctx.callActivity("MyFlakeyActivity1", null, optionsWithRetryHandler).get();
ctx.callActivity("MyFlakeyActivity2", null, optionsWithRetryHandler).get();
};

Code changes:

  • New public classes to support custom retry logic
  • Refactored integration tests to share common logic
  • Added support for non-retriable errors
  • Fixed bug with backoff coefficient

Resolves#18

- New public classes to support custom retry logic
- Refactored integration tests to share common logic
- Added support for non-retriable errors
- Fixed bug with backoff coefficient

@kaibocaikaibocai (kaibocai) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments, but overall looks pretty much ready to me. Just waiting to read responses to my comments before approving. In any case, I see now how the shim-less approach enables RetryHandles for OOProc. Exciting!

Comment threadsdk/src/main/java/com/microsoft/durabletask/TaskOptions.java
- Overflow handling
- API simplification
- Always use reflection for isCausedBy

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@cgillum
Chris Gillum (cgillum) deleted the cgillum/retry-handlers branch April 7, 2022 21:32
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Durable retry policies

3 participants

@cgillum@davidmrdavid@kaibocai