public class SynchronousCallback extends Object implements Repository.UnitOfWorkListener
Add an instance of this class to a transaction:
SynchronousCallback callback = new SynchronousCallback();
UnitOfWork transaction = repo.createTransaction("the-transaction", false, callback);
At the point of committing the transaction, do the following:
transaction.commit();
if (! callback.wait(3, TimeUnit.MINUTES)) throw someException
if (callback.hasError()) throw someException
This will hold the thread committing the transaction until it has completely finished.
Constructor and Description |
---|
SynchronousCallback() |
Modifier and Type | Method and Description |
---|---|
boolean |
await(long timeout,
TimeUnit unit)
Wait for the completion of the sequencers
|
Throwable |
error() |
void |
errorOccurred(Throwable error) |
boolean |
hasError() |
void |
respond(Object results) |
public boolean await(long timeout, TimeUnit unit) throws Exception
timeout
- the maximum time to waitunit
- the time unit of the timeout
argumenttrue
if the count reached zero and false
if the waiting time elapsed before the count reached zeroException
- if error occurspublic void respond(Object results)
respond
in interface Repository.UnitOfWorkListener
public void errorOccurred(Throwable error)
errorOccurred
in interface Repository.UnitOfWorkListener
public Throwable error()
public boolean hasError()
Copyright © 2013–2019. All rights reserved.