Class OutboxDispatcher
java.lang.Object
org.chenile.orchestrator.process.outbox.OutboxDispatcher
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 Summary
FieldsModifier and TypeFieldDescriptionprivate final OutboxCommandRegistryprivate final intprivate static final org.slf4j.Loggerprivate final ProcessOutboxRepositoryprivate final OutboxRetryPolicyprivate final String -
Constructor Summary
ConstructorsConstructorDescriptionOutboxDispatcher(ProcessOutboxRepository repository, OutboxCommandRegistry commands, OutboxRetryPolicy retryPolicy, String workerId, int lockSeconds) -
Method Summary
Modifier and TypeMethodDescriptionintdrainAll(int maxCommands) Drain until nothing is immediately due.private booleanexecute(OutboxCommand command) voidpoll()One background polling cycle; manual dispatch remains available when scheduling is disabled.boolean
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
repository
-
commands
-
retryPolicy
-
workerId
-
lockSeconds
private final int lockSeconds
-
-
Constructor Details
-
OutboxDispatcher
public OutboxDispatcher(ProcessOutboxRepository repository, OutboxCommandRegistry commands, OutboxRetryPolicy retryPolicy, String workerId, int lockSeconds)
-
-
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
-
CHENILE