Rifqi
Rifqi

Reputation: 63

Resilience4j Retry: Should you create singleton of Retry or create new one for every request?

As the title suggests, how should I implement Retry for multiple requests? I noticed that for every Retry, you must specify some Retry ID.

// Create a Retry with default configuration
Retry retry = Retry.ofDefaults("id");

How does the ID affects the execution? Will it affect concurrent requests using the same Retry ID?

Upvotes: 0

Views: 494

Answers (1)

Robert Winkler
Robert Winkler

Reputation: 1907

A single instance is sufficient. It won't affect concurrent requests. You can use the name of the service (backend system) which you want to protect as the ID, for example.

Upvotes: 1

Related Questions