Skip to content
This repository has been archived by the owner on Jun 21, 2023. It is now read-only.

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
elennick committed Feb 10, 2018
1 parent 51cd197 commit 6334267
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,12 @@ RetryConfig config = new RetryConfigBuilder()
.exponentialBackoff5Tries5Sec()
.build();

CallExecutor executor = new CallExecutor(config);

new CallExecutor<>(config)
.onSuccess(s -> System.out.println("Status after success: " + s))
.onFailure(s -> System.out.println("Failed! All retries exhausted..."))
.afterFailedTry(s -> System.out.println("Try failed! Will try again in 0ms."))
.beforeNextTry(s -> System.out.println("Trying again..."))
.onCompletion(s -> System.out.println("Retry execution complete!"))
CallExecutor executor = new CallExecutor<>(config)
.onSuccess(s -> { //do something on success })
.onFailure(s -> { //do something on a failed try })
.afterFailedTry(s -> { //do something after a failed try })
.beforeNextTry(s -> { //do something before the next try })
.onCompletion(s -> { //do some cleanup })
.execute(callable);
```

Expand Down Expand Up @@ -400,6 +398,18 @@ executor.onCompletion(s -> {
});
```

Listeners can be chained together:

```java
new CallExecutor<>(config)
.onSuccess(s -> System.out.println("Success!"))
.onCompletion(s -> System.out.println("Retry execution complete!"))
.onFailure(s -> System.out.println("Failed! All retries exhausted..."))
.afterFailedTry(s -> System.out.println("Try failed! Will try again in 0ms."))
.beforeNextTry(s -> System.out.println("Trying again..."))
.execute(callable);
```

### Async Support

Retry4j has some built in support for executing and retrying on one or more threads in an asynchronous fashion. The
Expand Down

0 comments on commit 6334267

Please sign in to comment.