Skip to content

Commit

Permalink
Fix the example code for skipping records to work properly (#719)
Browse files Browse the repository at this point in the history
Fixed the example code for skipping records to work properly.
Previously, the example code did not work correctly because retriesCount was constantly 0.

---------

Co-authored-by: Roman Kolesnev <88949424+rkolesnev@users.noreply.github.com>
Co-authored-by: John Byrne <33546417+johnbyrnejb@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 7, 2024
1 parent 8ca1f74 commit df4e7fd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ Implementing a https://github.com/confluentinc/parallel-consumer/issues/196[max
pc.poll(context -> {
var consumerRecord = context.getSingleRecord().getConsumerRecord();
Long retryCount = retriesCount.computeIfAbsent(consumerRecord, ignore -> 0L);
Long retryCount = retriesCount.compute(consumerRecord, (key, oldValue) -> oldValue == null ? 0L : oldValue + 1);
if (retryCount < maxRetries) {
processRecord(consumerRecord);
// no exception, so completed - remove from map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ void maxRetries() {

pc.poll(context -> {
var consumerRecord = context.getSingleRecord().getConsumerRecord();
Long retryCount = retriesCount.computeIfAbsent(consumerRecord, ignore -> 0L);
Long retryCount = retriesCount.compute(consumerRecord, (key, oldValue) -> oldValue == null ? 0L : oldValue + 1);
if (retryCount < maxRetries) {
processRecord(consumerRecord);
// no exception, so completed - remove from map
Expand Down

0 comments on commit df4e7fd

Please sign in to comment.