Class OutboxDispatcher

java.lang.Object
org.chenile.orchestrator.process.outbox.OutboxDispatcher

public class OutboxDispatcher extends Object
Drains the outbox: claims a due command, runs it through the OutboxCommandLifecycle, and marks it DONE or (on failure) applies the OutboxRetryPolicy.

processOne() does one command; drainAll(int) loops until nothing is due. Production schedules poll() (or scales replicas off ProcessOutboxRepository.backlogCount()); in-VM / test flows call drainAll on the calling thread right after the state-save transaction commits, preserving today's synchronous cascade semantics so the existing tests keep working.

  • Field Details

  • Constructor Details

  • Method Details

    • poll

      public void poll()
      One background polling cycle; manual dispatch remains available when scheduling is disabled.
    • processOne

      public boolean processOne()
      Returns:
      true if a command was claimed (success or failure), false if none was due.
    • drainAll

      public int drainAll(int maxCommands)
      Drain until nothing is immediately due. Used for synchronous in-VM execution. The bound guards against a pathological command that keeps re-enqueuing itself.
    • execute

      private boolean execute(OutboxCommand command)