"I'm using Redisson version 3.19.1 and have two ZSETs to store lists of read and unread messages. When a message is read, it needs to be moved from the unread list to the read list. To ensure atomicity, I'm using RBatch.
RBatch batch = redisson.createBatch(getBatchConfig()); RScoredSortedSetAsync<Long> userUnreadList = batch.getScoredSortedSet(UNREAD_MSG_PREFIX + cacheKey, new JsonJacksonCodec()); RScoredSortedSetAsync<Long> userReadList = batch.getScoredSortedSet(READ_MSG_PREFIX + cacheKey, new JsonJacksonCodec()); for (Long msgId : command.getMsgId()) { userUnreadList.getScoreAsync(msgId).thenAcceptAsync(score -> { log.info("cache update"); userReadList.addAsync(score, msgId); userUnreadList.removeAsync(msgId); }).exceptionallyAsync(ex -> { log.error("cache update error", ex); return null; }); } try { batch.execute(); } catch (Exception e) { log.error("cache write error", e); batch.discard(); throw e; }
After running the code, I found that the thenAcceptAsync
and exceptionallyAsync
methods were not executed, and there was no output in the log for "cache update" or "cache update error". However, monitoring the Redis console showed that the client read the two ZSETs.
What could be causing the thenAcceptAsync
method to not execute?"