-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JAMES-4081 Implement MailToAllUsers mailet #2469
base: master
Are you sure you want to change the base?
JAMES-4081 Implement MailToAllUsers mailet #2469
Conversation
Flux<Flux<MailAddress>> recipientsBatches = Flux.from(usersRepository.listReactive()) | ||
.map(Throwing.function(Username::asMailAddress)) | ||
.window(batchSize); | ||
|
||
Flux.merge(sendMailToFirstRecipientsBatchDirectly(mail, recipientsBatches), | ||
sendMailToRemainingRecipientsBatchAsynchronously(mail, recipientsBatches)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue is that we subscribe twice and the order might not be stable.
This means the first 100 items on the first subscriptions are not necessarily the ones of the next subscriptions.
How about:
Flux.from(usersRepository.listReactive())
.map(Throwing.function(Username::asMailAddress))
.window(batchSize);
.index()
.flatMap(tuple -> if (tuple.key() == 0) {
return sendMailToFirstRecipientsBatchDirectly(mail, tuple.value());
} else {
return sendMailToRemainingRecipientsBatchAsynchronously(mail, tuple.value());
}).then().block();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may use Flux.concat
as it would wait for the first Publisher to finish.
Or sendMailToFirstRecipientsBatchDirectly.then(sendMailToRemainingRecipientsBatchAsynchronously)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW recipientsBatches
is a cold publisher so is it supposed to produce data isolated regardless of subscribers?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes but because it is subscribed twice data may defer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
first call: a, b, c, d, e
=> send mail synchronously to a, b, c
second call d, e, b, a, c
=> send mail asynchrounously to a, c
- We called twice the ldap
- and we sent
a, b, c, a, c
and nota, b, c, d, e
No description provided.