@NotThreadSafe public interface ReplicationConnection extends AutoCloseable
| Modifier and Type | Interface and Description |
|---|---|
static interface |
ReplicationConnection.Builder
A builder for
ReplicationConnection |
| Modifier and Type | Method and Description |
|---|---|
static ReplicationConnection.Builder |
builder(Configuration jdbcConfig)
Creates a new
ReplicationConnection.Builder instance which can be used for creating replication connections. |
Optional<SlotCreationResult> |
createReplicationSlot()
Creates a new replication slot with the given option and returns the result of the command, which
may contain results (depending on postgres versions)
|
void |
initConnection()
Forces the connection to be created, is called by startStreaming, but can be called manually
in cases where we want the connection but not to to start streaming yet.
|
boolean |
isConnected()
Checks whether this connection is open or not
|
void |
reconnect() |
ReplicationStream |
startStreaming(Lsn offset,
WalPositionLocator walPosition)
Opens a stream for reading logical replication changes from a given LSN position.
|
ReplicationStream |
startStreaming(WalPositionLocator walPosition)
Opens a stream for reading logical replication changes from the last known position of the slot for which the connection
was opened.
|
closeReplicationStream startStreaming(WalPositionLocator walPosition) throws SQLException, InterruptedException
confirmed_flush_lsn value from the pg_replication_slots
table.
If there is no "last known value" (i.e. the connection is for a newly created slot) then the Postgres server will start streaming changes from that last position reported during this connection's creation.
PGReplicationStream from which data is read; never nullSQLException - if there is a problem obtaining the replication streamInterruptedExceptionReplicationStream startStreaming(Lsn offset, WalPositionLocator walPosition) throws SQLException, InterruptedException
Note that it is possible for a server to have recycled old WAL segments (see the wal_keep_segments setting). If
that is the case, then even though a LSN number may be valid, the server will not stream back any changes because they
are not available.
offset - a value representing the WAL sequence number where replication should start from; if the value
is null or negative, this behaves exactly like #startStreaming().PGReplicationStream from which data is read; never nullSQLException - if anything failsInterruptedExceptionLogSequenceNumberOptional<SlotCreationResult> createReplicationSlot() throws SQLException
SQLException - if anything failsvoid initConnection()
throws SQLException,
InterruptedException
SQLExceptionInterruptedExceptionboolean isConnected()
throws SQLException
true if this connection is open, false otherwiseSQLException - if anything unexpected failsstatic ReplicationConnection.Builder builder(Configuration jdbcConfig)
ReplicationConnection.Builder instance which can be used for creating replication connections.jdbcConfig - a Configuration instance that contains JDBC settings; may not be nullvoid reconnect()
throws SQLException
SQLExceptionCopyright © 2021 JBoss by Red Hat. All rights reserved.