snowdrop / vertx-spring-boot

Vert.x Spring Boot integration brings different Vert.x components to Spring Boot ecosystem
Apache License 2.0
137 stars 41 forks source link

Fix early subscription completion stage #35

Closed gytis closed 4 years ago

gytis commented 4 years ago

AMQP and Kafka modules extensively use the following structure: Mono.fromCompletionStage(delegate.methodReturningCompletionStage()). However, this does not postpone execution until the there is an actual subscription to mono.

For example with a still in process Kafka client the following would end up in a successful assignment:

interface KafkaConsumer {
  //...
  Mono<Void> assign(Partition partition);
  //...
}

class KafkaConsumerUser {
  //...
  public void useConsumer(Partition partition) {
    kafkaConsumer.assign(partition);
  }
}

We should replace those constructs with the following: Mono.fromCompletionStage(() -> delegate.methodReturningCompletionStage())