First instantiate and configure the template using the fluent API methods, and then invoke execute which will begin/commit transactions in a loop for the specified number of times.
By default all exceptions (except Errors and TransactionTerminatedException) cause a retry, and the monitor does nothing, but these can be overridden with custom behavior. A bit more narrow and typical exception to retry on is TransientFailureException, which aims to represent exceptions that are most likely to succeed after a retry.