没有 MULTI 的 ERR EXEC - spring redis+jedis [英] ERR EXEC without MULTI - spring redis+jedis

查看:112
本文介绍了没有 MULTI 的 ERR EXEC - spring redis+jedis的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 spring-data-redis 进行事务性操作时遇到异常

I meet with exception during a transactional operation with spring-data-redis

RedisTemplate<String,Object> cartCache;

public void create(final Cartline cartline) {
  Object txResults = cartCache.execute(new SessionCallback<List>() {
    public List execute(RedisOperations operations) throws DataAccessException {
      String cartId = cartline.getMemberId();
      String cartlineId = cartline.getCartlineId();
      operations.multi();    
      ......           
      return operations.exec();
    }
  });
}

redis.clients.jedis.exceptions.JedisDataException: ERR EXEC without MULTI
    at redis.clients.jedis.Protocol.processError(Protocol.java:115)
    at redis.clients.jedis.Protocol.process(Protocol.java:133)
    at redis.clients.jedis.Protocol.read(Protocol.java:202)
    at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:285)
    at redis.clients.jedis.Connection.getRawObjectMultiBulkReply(Connection.java:230)
    at redis.clients.jedis.Connection.getObjectMultiBulkReply(Connection.java:236)
    at redis.clients.jedis.Transaction.exec(Transaction.java:38)
    at org.springframework.data.redis.connection.jedis.JedisConnection.exec(JedisConnection.java:738)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at org.springframework.data.redis.core.CloseSuppressingInvocationHandler.invoke(CloseSuppressingInvocationHandler.java:57)
    at com.sun.proxy.$Proxy512.exec(Unknown Source)
    at org.springframework.data.redis.core.RedisTemplate$3.doInRedis(RedisTemplate.java:593)
    at org.springframework.data.redis.core.RedisTemplate$3.doInRedis(RedisTemplate.java:591)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:190)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:152)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:140)
    at org.springframework.data.redis.core.RedisTemplate.execRaw(RedisTemplate.java:591)
    at org.springframework.data.redis.core.RedisTemplate.exec(RedisTemplate.java:578)
    at com.znova.stone.cart.repository.impl.CartCacheImpl$1.execute(CartCacheImpl.java:51)
    at com.znova.stone.cart.repository.impl.CartCacheImpl$1.execute(CartCacheImpl.java:1)
    at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:217)

我读了这篇文章 ERR EXEC without MULTI - Jedis 表示多exec,我也启用了 redisTemplate.setEnableTransactionSupport(true);,错误仍然存​​在.

I read this post ERR EXEC without MULTI - Jedis which indicates a multi with exec, I also have redisTemplate.setEnableTransactionSupport(true); enabled, the error stood still.

我删除了 multi-exec 块中的操作逻辑,我发现那里没有任何区别,异常发生事件与零操作块.

I removed operation logic within the multi-exec block, I found there is no difference whatever is there, the exception happens event with a zero-operation block.

推荐答案

我遇到了同样的问题,并通过将 spring-data-redis 从 1.4.2.RELEASE 更新到 1.5.2.RELEASE 来修复它.

I had this same problem and fixed it by updating spring-data-redis from 1.4.2.RELEASE to 1.5.2.RELEASE.

这篇关于没有 MULTI 的 ERR EXEC - spring redis+jedis的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆