Package io.meeds.commons.digest.service
Class DigestOccurrenceProcessor
java.lang.Object
io.meeds.commons.digest.service.DigestOccurrenceProcessor
One occurrence of one frequency for one user, as a single transaction: the
claim of the occurrence (the guarded move of the watermark), the reading of
the waiting items, the building of the email, its row in the mail queue and
the deletion of the covered items commit together, or roll back together.
A crash in the middle leaves the watermark where it was, and the user is
simply served again at the next run: an item is late, never lost, and never
sent twice.
-
Constructor Summary
ConstructorsConstructorDescriptionDigestOccurrenceProcessor(DigestSettingStorage settingStorage, DigestScheduleStorage scheduleStorage, DigestMailBuilder mailBuilder, DigestMailQueueStorage mailQueueStorage) -
Method Summary
Modifier and TypeMethodDescriptionbooleanserve(DigestUserEntity user, io.meeds.commons.digest.model.DigestFrequency frequency, Instant now) Serves one occurrence.
-
Constructor Details
-
DigestOccurrenceProcessor
public DigestOccurrenceProcessor(DigestSettingStorage settingStorage, DigestScheduleStorage scheduleStorage, DigestMailBuilder mailBuilder, DigestMailQueueStorage mailQueueStorage)
-
-
Method Details
-
serve
@Transactional(rollbackFor=java.lang.Exception.class) public boolean serve(DigestUserEntity user, io.meeds.commons.digest.model.DigestFrequency frequency, Instant now) Serves one occurrence. Any exception rolls the whole occurrence back, claim included, and reaches the caller.- Parameters:
user- the work list row, as read when the candidates were selectedfrequency- the frequency duenow- the new watermark, the moment of the run- Returns:
- true when this worker got the occurrence (whether or not an email went out), false when another worker took it first
-