Package org.keycloak.connections.jpa
Class AsyncCommitIntegrator
java.lang.Object
org.keycloak.connections.jpa.AsyncCommitIntegrator
- All Implemented Interfaces:
org.hibernate.event.spi.PreDeleteEventListener,org.hibernate.event.spi.PreInsertEventListener,org.hibernate.event.spi.PreUpdateEventListener
public class AsyncCommitIntegrator
extends Object
implements org.hibernate.event.spi.PreInsertEventListener, org.hibernate.event.spi.PreUpdateEventListener, org.hibernate.event.spi.PreDeleteEventListener
Hibernate event listener that enables asynchronous commit for PostgreSQL transactions
that only modify entities implementing
AsynchronousCommitAllowed.
On PostgreSQL, issues SET LOCAL synchronous_commit TO OFF before commit when
all modified entities in the transaction allow it. This skips the WAL fsync wait,
improving throughput for ephemeral data. The database remains crash-consistent;
only the last few milliseconds of such transactions may be lost on a crash.
On non-PostgreSQL databases, registerListeners(EntityManagerFactory) is a no-op.
- Author:
- Alexander Schwartz
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanonPreDelete(org.hibernate.event.spi.PreDeleteEvent event) booleanonPreInsert(org.hibernate.event.spi.PreInsertEvent event) booleanonPreUpdate(org.hibernate.event.spi.PreUpdateEvent event) static voidregisterListeners(jakarta.persistence.EntityManagerFactory emf) Registers asynchronous commit listeners on the givenEntityManagerFactoryif the underlying database is PostgreSQL.
-
Constructor Details
-
AsyncCommitIntegrator
public AsyncCommitIntegrator()
-
-
Method Details
-
registerListeners
public static void registerListeners(jakarta.persistence.EntityManagerFactory emf) Registers asynchronous commit listeners on the givenEntityManagerFactoryif the underlying database is PostgreSQL. No-op for other databases. -
onPreInsert
public boolean onPreInsert(org.hibernate.event.spi.PreInsertEvent event) - Specified by:
onPreInsertin interfaceorg.hibernate.event.spi.PreInsertEventListener
-
onPreUpdate
public boolean onPreUpdate(org.hibernate.event.spi.PreUpdateEvent event) - Specified by:
onPreUpdatein interfaceorg.hibernate.event.spi.PreUpdateEventListener
-
onPreDelete
public boolean onPreDelete(org.hibernate.event.spi.PreDeleteEvent event) - Specified by:
onPreDeletein interfaceorg.hibernate.event.spi.PreDeleteEventListener
-