Search in sources :

Example 1 with TransactionOptions

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);
    }
}
Also used : TransactionOptions(org.redisson.api.TransactionOptions) RTransaction(org.redisson.api.RTransaction)

Example 2 with TransactionOptions

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();
}
Also used : RTransactionReactive(org.redisson.api.RTransactionReactive) TransactionOptions(org.redisson.api.TransactionOptions)

Aggregations

TransactionOptions (org.redisson.api.TransactionOptions)2 RTransaction (org.redisson.api.RTransaction)1 RTransactionReactive (org.redisson.api.RTransactionReactive)1