Neo4j get information of TransactionEventHandler

183 views Asked by At

Is there a way to retrieve the information (writeSet of Transaction) out of the TransactionEventHandler?

public class NewTransactionEventHandler<T> implements TransactionEventHandler<T>
{

    @Override
    public T beforeCommit(TransactionData transactionData)

I'd like to get that transactionData Object after the transaction finished successfully or unsuccessfully

2

There are 2 answers

2
raycons On

It is possible to set a Variable

public class NewTransactionEventHandler<T> implements TransactionEventHandler<T>
{
public int returnVariable = 0;
}

When you register the EventHandler

saveEventHandler= graphDb1.registerTransactionEventHandler(EventHandler);

you can access the eventHandler to get the data:

saveEventHandler.returnVariable;
6
Stefan Armbruster On

TransactionEventHandler.afterCommit and TransactionEventHandler.afterRollback is probably what you're looking for. TransactionData gives you access to the changes.