Skip to content

Commit 2c1fd39

Browse files
authored
content for Retry pattern
1 parent dec77dd commit 2c1fd39

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

docs/aac/java-mwa-guide.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -293,29 +293,9 @@ The [Retry pattern](/azure/architecture/patterns/retry) allows applications to r
293293
294294
- *Use exponential backoff.* Implement exponential backoff strategy for retry attempts. This means increasing the time between each retry exponentially, which helps reduce the load on the system during periods of high failure rates.
295295
296-
- *Use SDK Retry functionality.* For services with specialized SDKs, like Azure Service Bus or Azure Blob Storage, use the built-in retry mechanisms. The built-in retry mechanisms are optimized for the service's typical use cases and can handle retries more effectively with less configuration required on your part. For example, the reference implementation uses the built-in retry functionality of the Azure Service Bus SDK (`ServiceBusClient` and `ServiceBusRetryOptions`). The `ServiceBusRetryOptions` fetches settings from `MessageBusOptions` to configure retry settings such as MaxRetries, Delay, MaxDelay, and TryTimeout.
296+
- *Use SDK Retry functionality.* For services with specialized SDKs, like Azure Service Bus or Azure Blob Storage, use the built-in retry mechanisms. The built-in retry mechanisms are optimized for the service's typical use cases and can handle retries more effectively with less configuration required on your part.
297297
298-
```csharp
299-
// ServiceBusClient is thread-safe and can be reused for the lifetime of the application.
300-
services.AddSingleton(sp =>
301-
{
302-
var options = sp.GetRequiredService<IOptions<MessageBusOptions>>().Value;
303-
var clientOptions = new ServiceBusClientOptions
304-
{
305-
RetryOptions = new ServiceBusRetryOptions
306-
{
307-
Mode = ServiceBusRetryMode.Exponential,
308-
MaxRetries = options.MaxRetries,
309-
Delay = TimeSpan.FromSeconds(options.BaseDelaySecondsBetweenRetries),
310-
MaxDelay = TimeSpan.FromSeconds(options.MaxDelaySeconds),
311-
TryTimeout = TimeSpan.FromSeconds(options.TryTimeoutSeconds)
312-
}
313-
};
314-
return new ServiceBusClient(options.Host, azureCredential ?? new DefaultAzureCredential(), clientOptions);
315-
});
316-
```
317-
318-
- *Adopt standard resilience Libraries for HTTP Clients.* For HTTP communications, integrate a standard resilience library such as Polly or `Microsoft.Extensions.Http.Resilience`. These libraries offer comprehensive retry mechanisms that are crucial for managing communications with external web services.
298+
- *Adopt standard resilience Libraries for HTTP Clients.* For HTTP clients, you can use **Resilience4j** along with **Spring's RestTemplate** or **WebClient** to handle retries in HTTP communications. Spring's RestTemplate can be wrapped with Resilience4j's retry logic to handle transient HTTP errors effectively.
319299
320300
- *Handle message locking.* For message-based systems, implement message handling strategies that support retries without data loss, such as using "peek-lock" modes where available. Ensure that failed messages are retried effectively and moved to a dead-letter queue after repeated failures.
321301

0 commit comments

Comments
 (0)