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

Java Lettuce Reactive Pattern - Catch Errors?

$
0
0

I'm trying to use lettuce instead of Jedis for it's reactive pattern. Jedis can block my vertx eventloop and instead of making it a blocking operation I'd rather have it be reactive.

I can successfully fetch items from redis using lettuce but I haven't figured out how to handle exceptions. As an example-

// Attempt A: Is the error in otherstuff?redis.get(cacheKey).handle((response, otherstuff) -> {            ...        }).subscribe();// Attempt B: Do I add a doOnError?redis.get(cacheKey).handle((response, otherstuff) -> {            ...        }).doOnError((error) -> {            logger.error(err);        }).subscribe();// Attempt C: Do I add my callbacks to subscribe?redis.get(cacheKey).subscribe((response) -> {            ...        }, (err) -> {            logger.error(err);        });

The first confusion I have is how many ways I can do the same thing. I've found multiple ways to actually get a value, but I've found no way to catch an error. The cache key it's pulling from does not exist, my assumption is that an error would be thrown somewhere.

How do I catch lettuce errors?


Viewing all articles
Browse latest Browse all 2223

Latest Images

Trending Articles



Latest Images

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