Class PreparedTxnState
java.lang.Object
org.apache.kafka.clients.producer.PreparedTxnState
Class containing the state of a transaction after it has been prepared for a two-phase commit. This state includes the producer ID and epoch, which are needed to commit or abort the transaction.
Constructor Summary
ConstructorsConstructorDescriptionCreates a new empty PreparedTxnStatePreparedTxnState(String serializedState) Creates a new PreparedTxnState from a serialized string representationMethod Summary
Constructor Details
PreparedTxnState
public PreparedTxnState()Creates a new empty PreparedTxnStatePreparedTxnState
Creates a new PreparedTxnState from a serialized string representation- Parameters:
serializedState- The serialized string to deserialize.- Throws:
IllegalArgumentException- if the serialized string is not in the expected format
Method Details
producerId
public long producerId()epoch
public short epoch()hasTransaction
public boolean hasTransaction()Checks if this preparedTxnState represents an initialized transaction with a valid producer ID that is not -1 (the uninitialized value).- Returns:
- true if the state has an initialized transaction, false otherwise.
toString
Returns a serialized string representation of this transaction state. The format is "producerId:epoch" for an initialized state, or an empty string for an uninitialized state (where producerId and epoch are both -1).equals
hashCode