Package outbox.poller

Class OutboxPoller

java.lang.Object
outbox.poller.OutboxPoller
All Implemented Interfaces:
AutoCloseable

public final class OutboxPoller extends Object implements AutoCloseable
Scheduled database scanner that polls for pending outbox events as a fallback when the hot path is unavailable or events are dropped.

Supports claim-based locking via ownerId/lockTimeout for safe multi-instance deployments. Create instances via builder().

This class is thread-safe. The start() and close() methods are synchronized to prevent concurrent lifecycle transitions.

See Also:
  • Method Details

    • builder

      public static OutboxPoller.Builder builder()
    • start

      public void start()
      Starts the scheduled polling loop. Subsequent calls are no-ops if already started.
    • poll

      public void poll()
      Executes a single poll cycle. Called automatically by the scheduler, but may also be invoked directly for testing.
    • close

      public void close()
      Cancels the polling schedule and shuts down the scheduler thread.
      Specified by:
      close in interface AutoCloseable