Class PostgresOutboxStore

java.lang.Object
io.outbox.jdbc.store.AbstractJdbcOutboxStore
io.outbox.jdbc.store.PostgresOutboxStore
All Implemented Interfaces:
OutboxStore

public final class PostgresOutboxStore extends AbstractJdbcOutboxStore
PostgreSQL outbox store.

Uses FOR UPDATE SKIP LOCKED with RETURNING for single-round-trip claim.

  • Constructor Details

    • PostgresOutboxStore

      public PostgresOutboxStore()
    • PostgresOutboxStore

      public PostgresOutboxStore(String tableName)
  • Method Details

    • name

      public String name()
      Description copied from class: AbstractJdbcOutboxStore
      Unique identifier for this outbox store (e.g., "mysql", "postgresql", "h2").
      Specified by:
      name in class AbstractJdbcOutboxStore
    • jdbcUrlPrefixes

      public List<String> jdbcUrlPrefixes()
      Description copied from class: AbstractJdbcOutboxStore
      JDBC URL prefixes this outbox store handles (e.g., "jdbc:mysql:", "jdbc:tidb:").
      Specified by:
      jdbcUrlPrefixes in class AbstractJdbcOutboxStore
    • jsonPlaceholder

      protected String jsonPlaceholder()
      Description copied from class: AbstractJdbcOutboxStore
      Returns the SQL placeholder expression for JSON/JSONB columns.

      Defaults to "?" which works for H2 (CLOB) and MySQL (JSON). PostgreSQL overrides with "CAST(? AS jsonb)" because the JDBC driver rejects implicit VARCHAR-to-JSONB coercion.

      Overrides:
      jsonPlaceholder in class AbstractJdbcOutboxStore
    • claimPending

      public List<OutboxEvent> claimPending(Connection conn, String ownerId, Instant now, Instant lockExpiry, Duration skipRecent, int limit)
      Description copied from class: AbstractJdbcOutboxStore
      H2-compatible two-phase claim: UPDATE with subquery, then SELECT claimed rows.

      Not atomic under concurrent access. Two concurrent pollers may claim overlapping rows because H2 does not support FOR UPDATE SKIP LOCKED. This default is intended for testing and single-instance deployments only. Production multi-instance deployments should use PostgresOutboxStore or MySqlOutboxStore (both use FOR UPDATE SKIP LOCKED).

      Specified by:
      claimPending in interface OutboxStore
      Overrides:
      claimPending in class AbstractJdbcOutboxStore
      Parameters:
      conn - the JDBC connection
      ownerId - unique identifier for the claiming poller instance
      now - current timestamp
      lockExpiry - timestamp before which existing claims are considered expired
      skipRecent - duration to skip recently-created events
      limit - maximum number of events to claim
      Returns:
      list of claimed events