Interface ITransactionRecorder


  • @ProviderType
    public interface ITransactionRecorder
    An interface to record transactions by the billable services. It should preferably be used in the following fashion: try { startContext(); //do some billable work recordTransaction(txRecord); } catch (anyException e) { endContext(); }
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void discardTransaction()
      Discards the complete context and will not record any transaction in that context.
      void endContext()
      Ends the current transaction context and merges the transaction records passed in the whole context and clear the existing transaction context if its corresponding startContext call initiated a new context.
      void recordTransaction​(TransactionRecord transactionRecord)
      Records the TransactionRecord passed to it in an in-memory buffer.
      void startContext()
      Initiates a transaction context.
    • Method Detail

      • startContext

        void startContext()
        Initiates a transaction context. It needs to be called by every billable service API at the very beginning.
      • endContext

        void endContext()
        Ends the current transaction context and merges the transaction records passed in the whole context and clear the existing transaction context if its corresponding startContext call initiated a new context. The merged records are given to the storage provider for persistence. It must be called every time, preferably in a finally block.
      • discardTransaction

        void discardTransaction()
        Discards the complete context and will not record any transaction in that context. This is to handle the failure cases which may arise in nested API invocation case where some records are there with non-zero transaction count.