quantranhong1999 commented on code in PR #1467:
URL: https://github.com/apache/james-project/pull/1467#discussion_r1119517505
##########
server/mailet/mailets/src/main/java/org/apache/james/transport/mailets/delivery/MailDispatcher.java:
##########
@@ -172,10 +182,14 @@ private List<MailAddress> deliver(Mail mail, MimeMessage
message) {
}
private Mono<Void> storeMailWithRetry(Mail mail, MailAddress recipient) {
- return Mono.from(mailStore.storeMail(recipient, mail))
- .doOnError(error -> LOGGER.warn("Error While storing mail. This
error will be retried.", error))
- .retryWhen(Retry.backoff(RETRIES,
FIRST_BACKOFF).maxBackoff(MAX_BACKOFF).scheduler(Schedulers.parallel()))
- .then();
+ Mono<Void> operation = Mono.from(mailStore.storeMail(recipient, mail))
+ .doOnError(error -> LOGGER.warn("Error While storing mail. This
error will be retried.", error));
+
+ return retries.map(count ->
+ operation
+ .retryWhen(Retry.backoff(count,
FIRST_BACKOFF).maxBackoff(MAX_BACKOFF).scheduler(Schedulers.parallel()))
+ .then())
+ .orElse(operation);
Review Comment:
I think with this code, even when we do not do a retry or there are no
retries left, we still log "This error will be retried.". That could lead to
misunderstanding while observing.
I propose to count the remaining retry count:
```java
AtomicInteger remainRetries = new AtomicInteger(retries.orElse(0));
Mono<Void> operation = Mono.from(mailStore.storeMail(recipient,
mail))
.doOnError(error -> LOGGER.warn("Error While storing mail. This
error will be retried for {} more times.", remainRetries.getAndDecrement(),
error));
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]