Class DigestOccurrenceProcessor

java.lang.Object
io.meeds.commons.digest.service.DigestOccurrenceProcessor

@Component public class DigestOccurrenceProcessor extends Object
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 Details

  • 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 selected
      frequency - the frequency due
      now - 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