Repository: james-project Updated Branches: refs/heads/master b0687e850 -> e7048f41c
JAMES-2627 Reactor version for vacation mailet: don't use the Cassandra thread pool to wait for an other Cassandra request Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/e7048f41 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/e7048f41 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/e7048f41 Branch: refs/heads/master Commit: e7048f41c75c6b9f0b9ae4ebcd1fda885de8133b Parents: b0687e8 Author: Raphael Ouazana <[email protected]> Authored: Tue Dec 11 17:12:08 2018 +0100 Committer: Raphael Ouazana <[email protected]> Committed: Wed Dec 12 11:46:56 2018 +0100 ---------------------------------------------------------------------- server/protocols/jmap/pom.xml | 4 ++++ .../apache/james/jmap/mailet/VacationMailet.java | 17 +++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/e7048f41/server/protocols/jmap/pom.xml ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/pom.xml b/server/protocols/jmap/pom.xml index 49cd4d6..5ce01b6 100644 --- a/server/protocols/jmap/pom.xml +++ b/server/protocols/jmap/pom.xml @@ -203,6 +203,10 @@ <artifactId>jjwt</artifactId> </dependency> <dependency> + <groupId>io.projectreactor</groupId> + <artifactId>reactor-core</artifactId> + </dependency> + <dependency> <groupId>io.rest-assured</groupId> <artifactId>rest-assured</artifactId> <scope>test</scope> http://git-wip-us.apache.org/repos/asf/james-project/blob/e7048f41/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java index a692d08..ac50d14 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/mailet/VacationMailet.java @@ -20,7 +20,6 @@ package org.apache.james.jmap.mailet; import java.time.ZonedDateTime; -import java.util.concurrent.CompletableFuture; import javax.inject.Inject; import javax.mail.MessagingException; @@ -40,6 +39,9 @@ import org.apache.mailet.base.GenericMailet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; + public class VacationMailet extends GenericMailet { private static final Logger LOGGER = LoggerFactory.getLogger(VacationMailet.class); @@ -80,13 +82,12 @@ public class VacationMailet extends GenericMailet { private void manageVacation(MailAddress recipient, Mail processedMail, ZonedDateTime processingDate) { AccountId accountId = AccountId.fromString(recipient.toString()); - CompletableFuture<Vacation> vacationFuture = vacationRepository.retrieveVacation(accountId); - CompletableFuture<Boolean> alreadySentFuture = notificationRegistry.isRegistered( - AccountId.fromString(recipient.toString()), - RecipientId.fromMailAddress(processedMail.getMaybeSender().get())); - - Pair<Vacation, Boolean> pair = vacationFuture.thenCombine(alreadySentFuture, Pair::of) - .join(); + Mono<Vacation> vacation = Mono.fromCompletionStage(vacationRepository.retrieveVacation(accountId)); + Mono<Boolean> alreadySent = Mono.fromCompletionStage(notificationRegistry.isRegistered( + AccountId.fromString(recipient.toString()), + RecipientId.fromMailAddress(processedMail.getMaybeSender().get()))); + Pair<Vacation, Boolean> pair = Flux.combineLatest(vacation, alreadySent, Pair::of) + .blockFirst(); sendNotificationIfRequired(recipient, processedMail, processingDate, pair.getKey(), pair.getValue()); } --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
