Details
Description
When RabbitMQ is busy or has other problems during mail spooling, it will fail to acknowledge the attempt to publish the mail reference, see Enqueuer.publishReferenceToRabbit(). The Enqueuer will detect this and clean up the mail queue view, to remove the mail from blob storage, see Enqueuer.cleanupMailQueueView(). However, this uses .thenReturn(Mono.<Void>error(e)), i.e. a success Mono<Mono<Exception>>, which gets ignored afterwards. Consequently Enqueuer.enQueue() returns as a success as well, so the SendMailHandler reports the mail as "successfully spooled" to the sender while in reality it has already deleted it. The mail is lost.
The fix is to change Enqueuer.cleanupMailQueueView() to use .then(Mono.<Void>error(e)), i.e. a failure Mono<Exception>, which propagates the exception up the chain and makes Enqueuer.enQueue() throw. The SendMailHandler will report "error processing message" to the sender so it can retry later.