Interface Transaction<Type>

  • Type Parameters:
    Type - The type of events in the associated stream.

    public interface Transaction<Type>
    Provides a mechanism for writing many events atomically. A Transaction is unbounded in size but is bounded in time. If it has not been committed within a time window specified at the time of its creation it will be automatically aborted. All methods on this class may block.
    • Method Detail

      • getTxnId

        java.util.UUID getTxnId()
        Returns a unique ID that can be used to identify this transaction.
        Returns:
        Unique identifier of the transaction
      • writeEvent

        void writeEvent​(Type event)
                 throws TxnFailedException
        Sends an event to the stream just like EventStreamWriter.writeEvent(Type) but with the caveat that the message will not be visible to anyone until commit() is called. A routing key will automatically be inferred from the transactionID. So all events written this way will be fully ordered and contiguous when read.
        Parameters:
        event - The Event to write. (Null is disallowed)
        Throws:
        TxnFailedException - The Transaction is no longer in state Transaction.Status.OPEN
      • commit

        void commit()
             throws TxnFailedException
        Causes all messages previously written to the transaction to go into the stream contiguously. This operation will either fully succeed making all events consumable or fully fail such that none of them are. There may be some time delay before readers see the events after this call has returned.
        Throws:
        TxnFailedException - The Transaction is no longer in state Transaction.Status.OPEN
      • abort

        void abort()
        Drops the transaction, causing all events written to it to be deleted.
      • checkStatus

        Transaction.Status checkStatus()
        Gets the status of the transaction.
        Returns:
        Current status of the transaction