Package io.outbox.jdbc.store
Class PostgresOutboxStore
java.lang.Object
io.outbox.jdbc.store.AbstractJdbcOutboxStore
io.outbox.jdbc.store.PostgresOutboxStore
- All Implemented Interfaces:
OutboxStore
PostgreSQL outbox store.
Uses FOR UPDATE SKIP LOCKED with RETURNING for
single-round-trip claim.
-
Field Summary
Fields inherited from class io.outbox.jdbc.store.AbstractJdbcOutboxStore
DEFAULT_TABLE, EVENT_ROW_MAPPER, MAX_BATCH_ROWS, PENDING_STATUS_IN, TERMINAL_STATUS_IN -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclaimPending(Connection conn, String ownerId, Instant now, Instant lockExpiry, Duration skipRecent, int limit) H2-compatible two-phase claim: UPDATE with subquery, then SELECT claimed rows.JDBC URL prefixes this outbox store handles (e.g., "jdbc:mysql:", "jdbc:tidb:").protected StringReturns the SQL placeholder expression for JSON/JSONB columns.name()Unique identifier for this outbox store (e.g., "mysql", "postgresql", "h2").Methods inherited from class io.outbox.jdbc.store.AbstractJdbcOutboxStore
countDead, insertBatch, insertNew, jsonCodec, markDead, markDeferred, markDone, markRetry, pollPending, queryDead, recentCutoff, replayDead, selectClaimed, tableName
-
Constructor Details
-
PostgresOutboxStore
public PostgresOutboxStore() -
PostgresOutboxStore
-
-
Method Details
-
name
Description copied from class:AbstractJdbcOutboxStoreUnique identifier for this outbox store (e.g., "mysql", "postgresql", "h2").- Specified by:
namein classAbstractJdbcOutboxStore
-
jdbcUrlPrefixes
Description copied from class:AbstractJdbcOutboxStoreJDBC URL prefixes this outbox store handles (e.g., "jdbc:mysql:", "jdbc:tidb:").- Specified by:
jdbcUrlPrefixesin classAbstractJdbcOutboxStore
-
jsonPlaceholder
Description copied from class:AbstractJdbcOutboxStoreReturns 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:
jsonPlaceholderin classAbstractJdbcOutboxStore
-
claimPending
public List<OutboxEvent> claimPending(Connection conn, String ownerId, Instant now, Instant lockExpiry, Duration skipRecent, int limit) Description copied from class:AbstractJdbcOutboxStoreH2-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 usePostgresOutboxStoreorMySqlOutboxStore(both useFOR UPDATE SKIP LOCKED).- Specified by:
claimPendingin interfaceOutboxStore- Overrides:
claimPendingin classAbstractJdbcOutboxStore- Parameters:
conn- the JDBC connectionownerId- unique identifier for the claiming poller instancenow- current timestamplockExpiry- timestamp before which existing claims are considered expiredskipRecent- duration to skip recently-created eventslimit- maximum number of events to claim- Returns:
- list of claimed events
-