我正试图在Scala中按以下方式使用KafkaAdminClient.create
:
import java.util.Properties
import org.apache.kafka.clients.admin.KafkaAdminClient
final class DetectorActor extends TemplateActor {
val props = new Properties
props.put("bootstrap.servers", "localhost:9092")
props.put("connections.max.idle.ms", "10000")
props.put("request.timeout.ms", "5000")
val adminClient = {
val client = KafkaAdminClient.create(props)
}
override def receive: Receive = ???
}
,它不起作用,因为Scala
编译器找不到KafkaAdminClient.create(props)
工厂方法。
value create is not a member of object org.apache.kafka.clients.admin.KafkaAdminClient
[error] val client = KafkaAdminClient.create(props)
我在做什么错了?
答案 0 :(得分:1)
dfs <- ls(envir=env)[sapply(mget(ls(envir=env), env), is.data.frame)]
扩展了org.apache.kafka.clients.admin.KafkaAdminClient
。
后者具有静态方法org.apache.kafka.clients.admin.AdminClient
create(props: Properties): AdminClient
val client = AdminClient.create(props)
的scaladoc说
KafkaAdminClient