Class ProcessOutboxRepository

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

public class ProcessOutboxRepository extends Object
Atomic enqueue plus fenced, recoverable PostgreSQL dispatch leases.
  • Field Details

  • Constructor Details

  • Method Details

    • enqueue

      public boolean enqueue(OutboxCommand command)
    • claimNext

      public Optional<OutboxCommand> claimNext(String workerId, int lockSeconds, int maxAttempts)
    • handleAndComplete

      public void handleAndComplete(OutboxCommand command, OutboxCommandLifecycle<?> handler)
      Local handler mutations and acknowledgement commit together. External effects still require deduplication.
    • markDone

      public boolean markDone(OutboxCommand command)
    • acknowledge

      private boolean acknowledge(OutboxCommand command)
    • markFailure

      public boolean markFailure(OutboxCommand command, OutboxRetryPolicy policy, String message)
    • checkIdempotency

      public boolean checkIdempotency(String consumer, String key)
      Atomically claims a consumer/key pair; true allows the first effect, false skips a duplicate. The caller commits this receipt alongside the business mutation.
    • backlogCount

      public long backlogCount()
    • deadCount

      public long deadCount()
    • replayDead

      public boolean replayDead(String id)
      Explicit operator replay; consumers keep receipts, so already committed effects are not repeated.
    • findById

      public Optional<OutboxCommand> findById(String id)
    • findByIdempotencyKey

      public Optional<OutboxCommand> findByIdempotencyKey(String key)
    • findCommands

      public ProcessOutboxRepository.CommandPage findCommands(String type, String tenant, String id, String status, String payloadFragment, int page, int size)
      Bounded, tenant-scoped command history. JSON metadata is owned by the producer.
    • findByIds

      public List<OutboxCommand> findByIds(String type, String tenant, Set<String> ids)
    • map

      private OutboxCommand map(ResultSet rs) throws SQLException
      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

      private boolean present(String value)
    • instant

      private static Instant instant(ResultSet rs, String column) throws SQLException
      Throws:
      SQLException
    • timestamp

      private static Timestamp timestamp(Instant value)
    • trim

      private static String trim(String value)