This project has retired. For details please refer to its Attic page.
Apache Marmotta - KiWi Transaction Support

KiWi Transaction Support

OpenRDF Sesame already offers basic transaction handling and update notification support in any OpenRDF sail stack around a NotifyingSail. This module builds on this functionality to provide a mechanism for keeping track of all changes (added and removed triples) occurring between the time a transaction began and the time the transaction was committed or rolled back. The transaction data is then handed over to all registered transaction listeners at certain event points (in analogy to JPA we offer “before commit”, “after commit”, “on rollback”). Since the KiWi transaction support builds upon the NotifyingSail, it can be used in any OpenRDF sail stack, independently of the other KiWi modules.

Extended transaction support is e.g. used by the versioning component (each transaction is considered a unit of work or version) and by the reasoner (on transaction commit, the transaction data is handed to the incremental reasoner). It is also used by some extended Apache Marmotta and Linked Media Framework functionalities like the LMF Semantic Search.

Maven Artifact

To use the extended transaction support, include the following artifact in your Maven build file:


Code Usage

In your code, the KiWi extended transactions can easily be stacked into your sail stack around any NotifyingSail. Event listeners can be added/removed by calling the appropriate addTransactionListener and removeTransactionListener methods:

KiWiTransactionalSail sail = new KiWiTransactionalSail(new MemoryStore());
Repository repository = new SailRepository(sail);

The TransactionListener interface defines three methods:

  • beforeCommit(TransactionData data) is called just before the transaction actually carries out its commit to the database;
  • afterCommit(TransactionData data) is called immediately after the transaction has been committed to the database (i.e. you can rely on the data being persistent)
  • rollback(TransactionData data) is called when the transaction is rolled back (e.g. in case of an error)