Skip to content

Commit

Permalink
GH-333: Support currentLag() in doOnConsumer
Browse files Browse the repository at this point in the history
Resolves #333
  • Loading branch information
garyrussell authored Oct 18, 2023
1 parent ab9f851 commit 1a44d5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class ConsumerHandler<K, V> {
"resume",
"offsetsForTimes",
"beginningOffsets",
"endOffsets"
"endOffsets",
"currentLag"
));

private static final AtomicInteger COUNTER = new AtomicInteger();
Expand Down
8 changes: 7 additions & 1 deletion src/test/java/reactor/kafka/receiver/KafkaReceiverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.OptionalLong;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -288,12 +289,17 @@ public void manualAssignmentWithCommit() throws Exception {
receiverOptions = receiverOptions.commitInterval(Duration.ZERO)
.commitBatchSize(0)
.assignment(getTopicPartitions());
KafkaReceiver<Integer, String> receiver = KafkaReceiver.create(receiverOptions);
Flux<? extends ConsumerRecord<Integer, String>> kafkaFlux =
KafkaReceiver.create(receiverOptions)
receiver
.receive()
.delayUntil(r -> r.receiverOffset().commit())
.doOnSubscribe(s -> assignSemaphore.release());
sendReceiveWithSendDelay(kafkaFlux, Duration.ofMillis(1000), 0, 10);
OptionalLong lag = receiver
.doOnConsumer(consumer -> consumer.currentLag(getTopicPartitions().iterator().next()))
.block(Duration.ofSeconds(10));
assertThat(lag.isPresent()).isTrue();
}

@Test
Expand Down

0 comments on commit 1a44d5c

Please sign in to comment.