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

Spring Boot Redis StreamReceiver wait for an event to complete

$
0
0

I have an app which consumes events from redis stream using StreamReceiver, and a controller which is used to stop and start a particular system where the app updates the db and does some processing.

My requirement is: Whenever the system stop and start event is taking place, redis stream events shouldn't be processed to maintain the db in consistent state. Once the system start/stop is finished, it has to resume processing events. Can i know what is the best way to handle this.

My StreamReceiver code:

        Flux<MapRecord<String, String, String>> stream = streamReceiver.receiveAutoAck(consumer,                StreamOffset.create("events", ReadOffset.lastConsumed()));        stream.log().doOnNext(data -> {            try {    Service.processEventsNotificationMessage(data);            } catch (InterruptedException e) {                e.printStackTrace();            }        }).onErrorContinue((throwable, event) -> {            log.error("Error while processing the event {}. Cause: {}", event, throwable.getMessage());            ;        }).doOnTerminate(() -> {            log.info("Redis events stream terminated");        }).subscribe();```

Viewing all articles
Browse latest Browse all 2204

Trending Articles



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