Use distinct() when a Flux may publish the same value more than once but you want each value only once in the resulting Flux. Unlike filter(), which needs a Predicate to decide what passes through, distinct() filters out values already published. section 11.3.3
@Test
public void distinct() {
Flux<String> animalFlux = Flux.just(
"dog", "cat", "bird", "dog", "bird", "anteater")
.distinct();
StepVerifier.create(animalFlux)
.expectNext("dog", "cat", "bird", "anteater")
.verifyComplete();
}
The source publishes "dog" and "bird" twice. After distinct(), StepVerifier expects each only once: "dog", "cat", "bird", then "anteater". section 11.3.3



