0

May I know how to implement dead letter queue example for the below code? The same input record should be published to some dlq topic.

reactiveKafkaConsumerTemplate
                .receiveAutoAck()
                .map(ConsumerRecord::value)
                .flatMap(this::consumeWithRetry)
                .onErrorContinue((error, value)->log.error("something bad happened while consuming : {}", error.getMessage()))
                .retryWhen(Retry.backoff(30, Duration.of(10, ChronoUnit.SECONDS)))
                .subscribe();
public Mono<Void> consumeWithRetry(MessageRecord message){
   return consume(message)
          .retry(2);
}
public Mono<Void> consumeWithRetry(MessageRecord message){
   return Mono.defer(()->consume(message))
          .retry(2);
}
  • You could add `onErrorResume` after `retryWhen` and use producer to send message to DL topic. In addition , use `doOnError` instead of `onErrorContinue` to log the error. `onErrorContinue` is very special operator and not sure it's working correctly here https://github.com/reactor/reactor-core/issues/2184. – Alex Jun 07 '22 at 14:43
  • @Alex my issue is I don't have scope of the message inside onErrorResume or doOnError. Can you please let me know how to achieve it? – Rambabu Kokkiligadda Jun 08 '22 at 14:52

0 Answers0