Class TransactionOutbox

    • Method Detail

      • schedule

        public <T> T schedule​(Class<T> clazz)
        The main entry point for submitting new transaction outbox tasks.

        Returns a proxy of T which, when called, will instantly return and schedule a call of the real method to occur after the current transaction is committed (as such a transaction needs to be active and accessible from transactionManager)

        Usage:

        transactionOutbox.schedule(MyService.class)
           .runMyMethod("with", "some", "arguments");

        This will write a record to the database using the supplied Persistor and Instantiator, using the current database transaction, which will get rolled back if the rest of the transaction is, and thus never processed. However, if the transaction is committed, the real method will be called immediately afterwards using the supplied submitter. Should that fail, the call will be reattempted whenever flush() is called, provided at least attemptFrequency has passed since the time the task was last attempted.

        Type Parameters:
        T - The type to proxy.
        Parameters:
        clazz - The class to proxy.
        Returns:
        The proxy of T.
      • whitelist

        public boolean whitelist​(String entryId)
        Marks a blacklisted entry back to not blacklisted and resets the attempt count. Requires an active transaction and a transaction manager that supports thread local context.
        Parameters:
        entryId - The entry id.
        Returns:
        True if the whitelisting request was successful. May return false if another thread whitelisted the entry first.
      • whitelist

        public boolean whitelist​(String entryId,
                                 Object transactionContext)
        Marks a blacklisted entry back to not blacklisted and resets the attempt count. Requires an active transaction and a transaction manager that supports supplied context.
        Parameters:
        entryId - The entry id.
        transactionContext - The transaction context (TransactionManager implementation specific).
        Returns:
        True if the whitelisting request was successful. May return false if another thread whitelisted the entry first.
      • processNow

        public void processNow​(TransactionOutboxEntry entry)
        Processes an entry immediately in the current thread. Intended for use in custom implementations of Submitter and should not generally otherwise be called.
        Parameters:
        entry - The entry.