Class TxnCheckpointSvc


  • public class TxnCheckpointSvc
    extends Object

    Provides a transaction delivery checkpoint service.

    Examples

    Please find the transaction checkpoint examples below.

    Transaction Checkpoint Example

    This Groovy example shows if transaction check point should be performed.

     import com.avoka.tm.svc.TxnCheckpointSvc
    
     boolean neededCheckpoint = new TxnCheckpointSvc()
                               .doCheckpoint("checkpoint") 

    Transaction Complete Checkpoint Example

    This Groovy example shows how to add Completed the delivery checkpoint with the given name, if it does not already exists.

     import com.avoka.tm.svc.TxnCheckpointSvc;
    
     boolean addedCheckpoint = new TxnCheckpointSvc()
                               .complete("checkpoint") 

    Check for existence of 'Completed' checkpoint Example

    This Groovy example shows how to see whether a 'Completed' checkpoint with the specified name already exists for the submission.

     import com.avoka.tm.svc.TxnCheckpointSvc;
    
     boolean addedCheckpoint = new TxnCheckpointSvc()
                               .complete("checkpoint") 
    Since:
    5.0
    • Constructor Summary

      Constructors 
      Constructor Description
      TxnCheckpointSvc​(Txn txn)
      Create a transaction delivery checkpoint service for the given transaction.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearAll()
      Deletes all existing delivery checkpoints for the configured submission.
      boolean complete​(String name)
      Add a Completed the delivery checkpoint with the given name, if it does not already exists.
      boolean complete​(String name, String description)
      Add a Completed the delivery checkpoint with the given name, if it does not already exists.
      boolean doCheckpoint​(String name)
      Return true if the checkpoint should be performed, either hasn't been registered or an error has occurred previously.
      boolean doCheckpoint​(String name, String description)
      Return true if the checkpoint should be performed, either hasn't been registered or an error has occurred previously.
      void error​(String name, Object error)
      Add a Error the delivery checkpoint with the given name, if it does not already exists.
      boolean isCompleted​(String name)
      Return whether a 'Completed' checkpoint with the specified name already exists for the submission.
    • Constructor Detail

      • TxnCheckpointSvc

        public TxnCheckpointSvc​(Txn txn)
        Create a transaction delivery checkpoint service for the given transaction.
        Parameters:
        txn - the transaction value object (required)
    • Method Detail

      • doCheckpoint

        public boolean doCheckpoint​(String name)

        Return true if the checkpoint should be performed, either hasn't been registered or an error has occurred previously.

        If the checkpoint has not already been registered this method will create a new checkpoint.

        Parameters:
        name - the name of the checkpoint to check, and register if it doesn't exist (required)
        Returns:
        if the checkpoint needs to be performed or false if already completed
      • doCheckpoint

        public boolean doCheckpoint​(String name,
                                    String description)

        Return true if the checkpoint should be performed, either hasn't been registered or an error has occurred previously.

        If the checkpoint has not already been registered this method will create a new checkpoint.

        Parameters:
        name - the name of the checkpoint to check, and register if it doesn't exist (required)
        description - the checkpoint description (optional)
        Returns:
        if the checkpoint needs to be performed or false if already completed
        Since:
        4.2.0
      • isCompleted

        public boolean isCompleted​(String name)
        Return whether a 'Completed' checkpoint with the specified name already exists for the submission.
        Parameters:
        name - the checkpoint name (required)
        Returns:
        true if the 'Completed' checkpoint already exists
      • complete

        public boolean complete​(String name)
        Add a Completed the delivery checkpoint with the given name, if it does not already exists.
        Parameters:
        name - the checkpoint name (required)
        Returns:
        true if the new completed delivery checkpoint was added or false if the checkpoint was already present
      • complete

        public boolean complete​(String name,
                                String description)
        Add a Completed the delivery checkpoint with the given name, if it does not already exists.
        Parameters:
        name - the checkpoint name (required)
        description - the delivery checkpoint description (optional)
        Returns:
        true if the new completed delivery checkpoint was added or false if the checkpoint was already present
      • error

        public void error​(String name,
                          Object error)
        Add a Error the delivery checkpoint with the given name, if it does not already exists. If the passed in error object is an Throwable error it will be logged to the Error Log and associated with the Submission.
        Parameters:
        name - the checkpoint name (required)
        error - message the delivery checkpoint error message (optional)
      • clearAll

        public void clearAll()
        Deletes all existing delivery checkpoints for the configured submission. This method performs a database commit.