Just like we have our own datasource bean (for JDBC) or connection factory (for JMS), we offer a "repository" class for JTA/XA with AllegroGraph.
import com.atomikos.allegrograph.AtomikosRepository; import org.eclipse.rdf4j.repository.RepositoryConnection; import com.atomikos.icatch.jta.UserTransactionManager; ... AGRepository allegroGraphRepository = ... //your normal AllegroGraph setup AtomikosRepository atomikosRepository = AtomikosRepository.createAtomikosRepository(allegroGraphRepository);Any transactional methods of interface org.eclipse.rdf4j.repository.RepositoryConnection will now use XA:
UserTransactionManager utm = new UserTransactionManager(); utm.begin(); RepositoryConnection connection = atomikosRepository.getConnection(); connection.add(...); //will trigger JTA/XA enlist in the current transaction connection.close(); utm.commit();
Instead of calling begin() and commit() on the UserTransactionManager, you can also use Spring's @Transactional annotation. That also works.