use of org.redisson.api.TransactionOptions in project redisson by redisson.
the class RedissonTransactionManager method doBegin.
@Override
protected void doBegin(Object transaction, TransactionDefinition definition) throws TransactionException {
RedissonTransactionObject tObject = (RedissonTransactionObject) transaction;
if (tObject.getTransactionHolder() == null) {
int timeout = determineTimeout(definition);
TransactionOptions options = TransactionOptions.defaults();
if (timeout != TransactionDefinition.TIMEOUT_DEFAULT) {
options.timeout(timeout, TimeUnit.SECONDS);
}
RTransaction trans = redisson.createTransaction(options);
RedissonTransactionHolder holder = new RedissonTransactionHolder();
holder.setTransaction(trans);
tObject.setTransactionHolder(holder);
TransactionSynchronizationManager.bindResource(redisson, holder);
}
}
use of org.redisson.api.TransactionOptions in project redisson by redisson.
the class ReactiveRedissonTransactionManager method doBegin.
@Override
protected Mono<Void> doBegin(TransactionSynchronizationManager synchronizationManager, Object transaction, TransactionDefinition definition) throws TransactionException {
ReactiveRedissonTransactionObject tObject = (ReactiveRedissonTransactionObject) transaction;
TransactionOptions options = TransactionOptions.defaults();
if (definition.getTimeout() != TransactionDefinition.TIMEOUT_DEFAULT) {
options.timeout(definition.getTimeout(), TimeUnit.SECONDS);
}
RTransactionReactive trans = redissonClient.createTransaction(options);
ReactiveRedissonResourceHolder holder = new ReactiveRedissonResourceHolder();
holder.setTransaction(trans);
tObject.setResourceHolder(holder);
synchronizationManager.bindResource(redissonClient, holder);
return Mono.empty();
}
Aggregations