Interface Checkpointer

  • All Superinterfaces:
    java.lang.AutoCloseable

    public interface Checkpointer
    extends java.lang.AutoCloseable
    Persists the current block and transactions within that block to enable event listening to be resumed following an application outage.

    Default implementations can be obtained from DefaultCheckpointers. Application developers are encouraged to build their own implementations that use a persistent store suitable to their environment.

    Implementations must be thread-safe.

    • Field Detail

      • UNSET_BLOCK_NUMBER

        static final long UNSET_BLOCK_NUMBER
        Block number indicating no stored value. This is the the default for a newly created checkpointer with no previously saved state.
        See Also:
        Constant Field Values
    • Method Detail

      • getBlockNumber

        long getBlockNumber()
                     throws java.io.IOException
        Get the current block number, or UNSET_BLOCK_NUMBER if there is no previously saved state.
        Returns:
        A block number.
        Throws:
        java.io.IOException - if the checkpointer fails to access persistent state.
      • setBlockNumber

        void setBlockNumber​(long blockNumber)
                     throws java.io.IOException
        Set the current block number. Also clears the stored transaction IDs. Typically set when the previous block has been processed.
        Parameters:
        blockNumber - A block number.
        Throws:
        java.io.IOException - if the checkpointer fails to access persistent state.
      • getTransactionIds

        java.util.Set<java.lang.String> getTransactionIds()
                                                   throws java.io.IOException
        Get the transaction IDs processed within the current block.
        Returns:
        Transaction IDs.
        Throws:
        java.io.IOException - if the checkpointer fails to access persistent state.
      • addTransactionId

        void addTransactionId​(java.lang.String transactionId)
                       throws java.io.IOException
        Add a transaction ID for the current block. Typically called once a transaction has been processed.
        Parameters:
        transactionId - A transaction ID.
        Throws:
        java.io.IOException - if the checkpointer fails to access persistent state.
      • close

        void close()
            throws java.io.IOException
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.io.IOException