private void processSessionRepl(ClusteredSession<O> session) {
// If we are using SESSION granularity, we don't want to initiate a TX
// for a single put
boolean notSession = (this.getReplicationGranularity() != ReplicationGranularity.SESSION);
boolean doTx = false;
BatchingManager batchingManager = this.distributedCacheManager.getBatchingManager();
try {
// We need transaction so all the replication are sent in batch.
// Don't do anything if there is already transaction context
// associated with this thread.
if (notSession && batchingManager.isBatchInProgress() == false) {
batchingManager.startBatch();
doTx = true;
}
session.processSessionReplication();
} catch (Exception ex) {
log.debug("processSessionRepl(): failed with exception", ex);
try {
// if(doTx)
// Let's setRollbackOnly no matter what.
// (except if there's no tx due to SESSION (JBAS-3840))
if (notSession)
batchingManager.setBatchRollbackOnly();
} catch (Exception exn) {
log.error("Caught exception rolling back transaction", exn);
}
// We will need to alert Tomcat of this exception.
if (ex instanceof RuntimeException)
throw (RuntimeException) ex;
throw new RuntimeException("JBossCacheManager.processSessionRepl(): failed to replicate session.", ex);
} finally {
if (doTx) {
batchingManager.endBatch();
}
}
}