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();```