public interface CacheStoreSessionListener
The most common use case for session listeners is database connection and transaction management. Store can be invoked one or several times during one session, depending on whether it's executed within cache transaction or not. In any case, you have to create a connection when session is started and commit it or rollback when session is finished.
Cache store session listener allows to implement this and other scenarios providing two callback methods:
onSessionStart(CacheStoreSession)
- called
when a session is created prior to all operations
within his session.
onSessionEnd(CacheStoreSession, boolean)
- called
after all operations within a session are invoked.
CacheJdbcStoreSessionListener
- JDBC-based session
listener. For each session it gets a new JDBC connection from
provided DataSource
and commits (or rolls back) it
when session ends.
CacheSpringStoreSessionListener
-
session listener based on Spring transaction management.
It starts a new DB transaction for each session and commits
(or rolls back) it when session ends. If there is no ongoing
cache transaction, this listener is no-op.
CacheHibernateStoreSessionListener
-
Hibernate-based session listener. It creates a new Hibernate
session for each Ignite session. If there is an ongoing cache
transaction, a corresponding Hibernate transaction is created
as well.
IgniteConfiguration.setCacheStoreSessionListenerFactories(Factory[])
configuration property. This will we called for any store
session, not depending on what caches participate in
transaction.
CacheConfiguration.setCacheStoreSessionListenerFactories(Factory[])
configuration property. This will be called only if the
cache participates in transaction.
CacheJdbcStoreSessionListener
can be configured in Spring XML configuration file:
<bean class="org.apache.ignite.configuration.IgniteConfiguration"> ... <property name="CacheStoreSessionListenerFactories"> <list> <bean class="javax.cache.configuration.FactoryBuilder$SingletonFactory"> <constructor-arg> <bean class="org.apache.ignite.cache.store.jdbc.CacheJdbcStoreSessionListener"> <!-- Inject external data source. --> <property name="dataSource" ref="jdbc-data-source"/> </bean> </constructor-arg> </bean> </list> </property> </bean>
Modifier and Type | Method and Description |
---|---|
void |
onSessionEnd(CacheStoreSession ses,
boolean commit)
On session end callback.
|
void |
onSessionStart(CacheStoreSession ses)
On session start callback.
|
void onSessionStart(CacheStoreSession ses)
Called before any store operation within a session is invoked.
ses
- Current session.void onSessionEnd(CacheStoreSession ses, boolean commit)
Called after all operations within a session are invoked.
ses
- Current session.commit
- True
if persistence store transaction
should commit, false
for rollback.
GridGain In-Memory Computing Platform : ver. 8.9.19 Release Date : April 10 2025