Class NotificationSupervisor.Builder

java.lang.Object
com.pyranid.NotificationSupervisor.Builder
Enclosing class:
NotificationSupervisor

@NotThreadSafe public static final class NotificationSupervisor.Builder extends Object
Builder for a single-use supervisor. No work starts until NotificationSupervisor.start().
Since:
4.8.0
Author:
Mark Allen
  • Method Details

    • channels

      Sets the nonempty, fixed channel set, copying it immediately.
      Parameters:
      channels - channels to register
      Returns:
      this builder
    • reconcile

      Sets bounded, repeatable reconciliation, requested after registration and each nonempty batch. Managed workers also serve optional polling; requests share a successful pass begun after each request.
      Parameters:
      reconciler - application operation that reads or claims authoritative durable state
      Returns:
      this builder
    • pollEvery

      Enables an immediate poll and subsequent fixed-delay reconciliation independent of listener I/O/backoff. Recoverable database failures are retried by later polls without reconnecting the listener.
      Parameters:
      interval - positive delay after a pass before the next periodic pass
      Returns:
      this builder
    • threadFactory

      Customizes managed workers by logical role. The function is resolved at start, not per task, and must return non-null factories producing distinct new, unstarted threads. The supervisor owns those workers.
      Parameters:
      factoryForRole - role-to-factory mapping; omit this setting to use named daemon workers
      Returns:
      this builder
    • onReconciliationFailure

      Observes recoverable managed reconciliation failures. Runs on the reconciliation worker, outside locks; it must be bounded and must not await shutdown. An observer failure terminates the supervisor.
      Parameters:
      observer - failure observer
      Returns:
      this builder
    • retry

      Enables explicit retry classification and backoff, including during startup.

      A retryable startup failure leaves first readiness pending. Reconciliation failures are offered to the policy only when they are DatabaseExceptions. Unsupported capabilities, other application exceptions, errors, and failures in the policy terminate. Stop or interruption prevents retries and preserves observed failures. With managed polling enabled, recoverable reconciliation failures await the next poll instead of reconnecting; listener open/receive/cleanup failures still use this policy.

      Parameters:
      condition - decides whether a database failure is retryable
      backoff - chooses a nonnegative delay after each selected failure
      stabilityWindow - positive established-session duration needed to reset consecutive failure escalation
      Returns:
      this builder
    • build

      Builds a supervisor without acquiring resources. Channels and reconciliation are required.
      Returns:
      a new, unstarted supervisor
      Throws:
      IllegalStateException - if channels or reconciliation have not been configured