I have the following code, that does not compile:
import akka.NotUsed
import akka.actor.typed.Behavior
import akka.actor.typed.scaladsl.Behaviors
import akka.pattern.FutureRef
import akka.stream.scaladsl._
import akka.stream.typed.scaladsl.ActorMaterializer
import org.apache.kafka.clients.admin._
import scala.jdk.FutureConverters._
import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.duration
object KafkaDetectorActor {
val create: Behavior[NotUsed] = Behaviors.setup { context =>
implicit val system = context.system
implicit val materializer = ActorMaterializer()
implicit val dispatcher = context.system.dispatchers
Behaviors.same
}
private def health(server: String)(implicit executor: ExecutionContext): Future[Boolean] = {
val props = new Properties
props.put(AdminClientConfig.BOOTSTRAP_SERVERS_CONFIG, server)
props.put(AdminClientConfig.CONNECTIONS_MAX_IDLE_MS_CONFIG, "10000")
props.put(AdminClientConfig.REQUEST_TIMEOUT_MS_CONFIG, "5000")
AdminClient
.create(props)
.listTopics()
.names()
.asScala
}
where names
returns KafkaFuture[java.util.Set[String]]
.
It does not recognize asScala
method. The scala.jdk.FutureConverters._
library is imported. What am I doing wrong?