Class ProcessOutboxRepository
java.lang.Object
org.chenile.orchestrator.process.outbox.ProcessOutboxRepository
Atomic enqueue plus fenced, recoverable PostgreSQL dispatch leases.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TransactionTemplateprivate final JdbcTemplateprivate final TenantScope -
Constructor Summary
ConstructorsConstructorDescriptionProcessOutboxRepository(JdbcTemplate jdbc, PlatformTransactionManager manager) ProcessOutboxRepository(JdbcTemplate jdbc, PlatformTransactionManager manager, TenantScope tenantScope) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanacknowledge(OutboxCommand command) longbooleancheckIdempotency(String consumer, String key) Atomically claims a consumer/key pair; true allows the first effect, false skips a duplicate.longbooleanenqueue(OutboxCommand command) findCommands(String type, String tenant, String id, String status, String payloadFragment, int page, int size) Bounded, tenant-scoped command history.voidhandleAndComplete(OutboxCommand command, OutboxCommandLifecycle<?> handler) Local handler mutations and acknowledgement commit together.private static Instantprivate OutboxCommandbooleanmarkDone(OutboxCommand command) booleanmarkFailure(OutboxCommand command, OutboxRetryPolicy policy, String message) private booleanbooleanreplayDead(String id) Explicit operator replay; consumers keep receipts, so already committed effects are not repeated.private voidOutbox writes and receipts must commit with the caller's business change, so they need the caller's transaction and its connection.private static Timestampprivate static String
-
Field Details
-
jdbc
-
independent
-
tenantScope
-
-
Constructor Details
-
ProcessOutboxRepository
-
ProcessOutboxRepository
public ProcessOutboxRepository(JdbcTemplate jdbc, PlatformTransactionManager manager, TenantScope tenantScope) - Parameters:
tenantScope- tells which tenant's database a command was claimed from, when the poller is draining one tenant at a time; may be null
-
-
Method Details
-
enqueue
-
claimNext
-
handleAndComplete
Local handler mutations and acknowledgement commit together. External effects still require deduplication. -
markDone
-
acknowledge
-
markFailure
-
checkIdempotency
-
backlogCount
public long backlogCount() -
deadCount
public long deadCount() -
replayDead
Explicit operator replay; consumers keep receipts, so already committed effects are not repeated. -
findById
-
findByIdempotencyKey
-
findCommands
-
findByIds
-
map
- Throws:
SQLException
-
requireTransaction
private void requireTransaction()Outbox writes and receipts must commit with the caller's business change, so they need the caller's transaction and its connection. If the transaction manager holds no connection for the JdbcTemplate's DataSource, the two use different DataSources and the write would commit on its own; that is a configuration error, reported here rather than discovered as lost atomicity. -
present
-
instant
- Throws:
SQLException
-
timestamp
-
trim
-
CHENILE