Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose manual stop method in KafkaReceiver #380

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix test & imports
  • Loading branch information
cjlee38 committed Jan 17, 2024
commit a1539bfd89f907fd969d9f6d56460c3848eaf2c1
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import org.apache.kafka.common.TopicPartition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.Disposable;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
Expand Down
8 changes: 5 additions & 3 deletions src/test/java/reactor/kafka/receiver/KafkaReceiverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1482,13 +1482,15 @@ public void stop() throws Exception {
CountDownLatch latch = new CountDownLatch(receiveCount);

KafkaReceiver<Integer, String> receiver = createReceiver();
Disposable disposable = subscribe(receiver.receive().delayElements(Duration.ofMillis(100)), latch);
Flux<ReceiverRecord<Integer, String>> flux = receiver.receive()
.delayElements(Duration.ofMillis(100L))
.flatMap(record -> Mono.delay(Duration.ofMillis(100)).then(Mono.just(record)));
Disposable disposable = subscribe(flux, latch);
sendMessages(receiveStartIndex, receiveCount);

Thread.sleep(1000L);
receiver.stop().subscribe(
__ -> {
/* do nothing */
ignored -> {
},
e -> fail(e.getMessage()),
() -> shutdown.set(true)
Expand Down