Equivalent of kafkaConsumer.partitionsFor using reactive kafka (akka kafka streams)

129 Views Asked by At

I'm using reactive-kafka (akka kafka streams):

https://doc.akka.io/docs/akka-stream-kafka/current/consumer.html

What is the equivalent of the below code using reactive-kafka?

import org.apache.kafka.clients.consumer.KafkaConsumer
...
val properties = new Properties()
properties.put("bootstrap.servers", "kafka:9092")

val kafkaConsumer = new KafkaConsumer[String, String](properties)
kafkaConsumer.partitionsFor("my-topic")
1

There are 1 best solutions below

0
On BEST ANSWER

This is not currently exposed directly in the Reactive Kafka API.

This is probably because Reactive Kafka focuses on streaming events in a reactive way to/from Akka-Streams based consumers/producers.

You can still use the official Kafka client to get a consumer to fetch the metadata from a cluster. This does not require additional dependencies, as it is brought in by Reactive Kafka.