Class Wal2JsonReplicationMessage
- java.lang.Object
-
- io.debezium.connector.postgresql.connection.wal2json.Wal2JsonReplicationMessage
-
- All Implemented Interfaces:
ReplicationMessage
class Wal2JsonReplicationMessage extends Object implements ReplicationMessage
Replication message representing message sent by the wal2json logical decoding plug-in.- Author:
- Jiri Pechanec
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface io.debezium.connector.postgresql.connection.ReplicationMessage
ReplicationMessage.Column, ReplicationMessage.ColumnTypeMetadata, ReplicationMessage.ColumnValue<T>, ReplicationMessage.NoopMessage, ReplicationMessage.Operation, ReplicationMessage.TransactionMessage
-
-
Field Summary
Fields Modifier and Type Field Description private InstantcommitTimeprivate booleanhasMetadataprivate booleanlastEventForLsnprivate static org.slf4j.LoggerLOGGERprivate DocumentrawMessageprivate longtxIdprivate TypeRegistrytypeRegistry
-
Constructor Summary
Constructors Constructor Description Wal2JsonReplicationMessage(long txId, Instant commitTime, Document rawMessage, boolean hasMetadata, boolean lastEventForLsn, TypeRegistry typeRegistry)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InstantgetCommitTime()List<ReplicationMessage.Column>getNewTupleList()List<ReplicationMessage.Column>getOldTupleList()ReplicationMessage.OperationgetOperation()StringgetTable()longgetTransactionId()ObjectgetValue(String columnName, PostgresType type, String fullType, Value rawValue, PostgresStreamingChangeEventSource.PgConnectionSupplier connection, boolean includeUnknownDatatypes)Converts the value (string representation) coming from wal2json plugin to a Java value based on the type of the column from the message.booleanhasTypeMetadata()booleanisLastEventForLsn()private StringparseType(String columnName, String typeWithModifiers)private List<ReplicationMessage.Column>transform(Document data, String nameField, String typeField, String valueField, String optionalsField)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.debezium.connector.postgresql.connection.ReplicationMessage
isTransactionalMessage, shouldSchemaBeSynchronized
-
-
-
-
Field Detail
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
txId
private final long txId
-
commitTime
private final Instant commitTime
-
rawMessage
private final Document rawMessage
-
hasMetadata
private final boolean hasMetadata
-
lastEventForLsn
private final boolean lastEventForLsn
-
typeRegistry
private final TypeRegistry typeRegistry
-
-
Constructor Detail
-
Wal2JsonReplicationMessage
public Wal2JsonReplicationMessage(long txId, Instant commitTime, Document rawMessage, boolean hasMetadata, boolean lastEventForLsn, TypeRegistry typeRegistry)
-
-
Method Detail
-
getOperation
public ReplicationMessage.Operation getOperation()
- Specified by:
getOperationin interfaceReplicationMessage- Returns:
- A data operation executed
-
getCommitTime
public Instant getCommitTime()
- Specified by:
getCommitTimein interfaceReplicationMessage- Returns:
- Transaction commit time for this change
-
getTransactionId
public long getTransactionId()
- Specified by:
getTransactionIdin interfaceReplicationMessage- Returns:
- An id of transaction to which this change belongs
-
getTable
public String getTable()
- Specified by:
getTablein interfaceReplicationMessage- Returns:
- Table changed
-
getOldTupleList
public List<ReplicationMessage.Column> getOldTupleList()
- Specified by:
getOldTupleListin interfaceReplicationMessage- Returns:
- Set of original values of table columns, null for INSERT
-
getNewTupleList
public List<ReplicationMessage.Column> getNewTupleList()
- Specified by:
getNewTupleListin interfaceReplicationMessage- Returns:
- Set of new values of table columns, null for DELETE
-
hasTypeMetadata
public boolean hasTypeMetadata()
- Specified by:
hasTypeMetadatain interfaceReplicationMessage- Returns:
- true if type metadata are passed as a part of message
-
transform
private List<ReplicationMessage.Column> transform(Document data, String nameField, String typeField, String valueField, String optionalsField)
-
getValue
public Object getValue(String columnName, PostgresType type, String fullType, Value rawValue, PostgresStreamingChangeEventSource.PgConnectionSupplier connection, boolean includeUnknownDatatypes)
Converts the value (string representation) coming from wal2json plugin to a Java value based on the type of the column from the message. This value will be converted later on if necessary by thePostgresValueConverter#converter(Column, Field)instance to match whatever the Connect schema type expects. Note that the logic here is tightly coupled (i.e. dependent) on the wal2json plugin logic which writes the actual JSON messages.- Parameters:
a- supplier to get a connection to Postgres instance for array handling- Returns:
- the value; may be null
-
isLastEventForLsn
public boolean isLastEventForLsn()
- Specified by:
isLastEventForLsnin interfaceReplicationMessage- Returns:
- true if this is the last message in the batch of messages with same LSN
-
-