Skip to content

How can detect last retry? #362

Answered by garyrussell
donghoon-khan asked this question in Q&A
Discussion options

You must be logged in to vote

There is no such mechanism available.

One work around would be to use a property for the max attempts, together with a label.

@Value("${test3.max}") int test3Max;
...
@Retryable(
        value = {Exception.class},
        maxAttemptsExpression = "#{'${test3.max}'}",
        label = "test3"
)
public void test3() {}

...and use the same property in your listener.

The label is available in the RetryContext under the RetryContext.NAME property.

	/**
	 * Retry context attribute name for reporting key. Can be used for reporting purposes,
	 * for instance in a retry listener, to accumulate data about the performance of a
	 * retry.
	 */
	String NAME = "context.name";

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@garyrussell
Comment options

@e-ivaldi
Comment options

@garyrussell
Comment options

@e-ivaldi
Comment options

Answer selected by donghoon-khan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants