public class TransactionTemplate extends Object
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.
Modifier and Type | Class and Description |
---|---|
static interface |
TransactionTemplate.Monitor |
Constructor and Description |
---|
TransactionTemplate() |
TransactionTemplate(org.neo4j.graphdb.GraphDatabaseService gds,
TransactionTemplate.Monitor monitor,
int retries,
long backoff,
Predicate<Throwable> retryPredicate) |
Modifier and Type | Method and Description |
---|---|
TransactionTemplate |
backoff(long backoff,
TimeUnit unit) |
void |
execute(Consumer<org.neo4j.graphdb.Transaction> txConsumer) |
<T> T |
execute(Function<org.neo4j.graphdb.Transaction,T> txFunction) |
TransactionTemplate |
monitor(TransactionTemplate.Monitor monitor) |
TransactionTemplate |
retries(int retries) |
TransactionTemplate |
retryOn(Predicate<Throwable> retryPredicate) |
TransactionTemplate |
with(org.neo4j.graphdb.GraphDatabaseService gds) |
public TransactionTemplate()
public TransactionTemplate(org.neo4j.graphdb.GraphDatabaseService gds, TransactionTemplate.Monitor monitor, int retries, long backoff, Predicate<Throwable> retryPredicate)
public TransactionTemplate with(org.neo4j.graphdb.GraphDatabaseService gds)
public TransactionTemplate retries(int retries)
public TransactionTemplate backoff(long backoff, TimeUnit unit)
public TransactionTemplate monitor(TransactionTemplate.Monitor monitor)
public TransactionTemplate retryOn(Predicate<Throwable> retryPredicate)
public void execute(Consumer<org.neo4j.graphdb.Transaction> txConsumer)
public <T> T execute(Function<org.neo4j.graphdb.Transaction,T> txFunction) throws org.neo4j.graphdb.TransactionFailureException
org.neo4j.graphdb.TransactionFailureException
Copyright © 2002–2016 The Neo4j Graph Database Project. All rights reserved.