Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

Redisson RBatch not executing thenAcceptAsync method

$
0
0

"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?"


Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>