我想将数据流从基于 mosquitto 的 MQTT 主题读取到我的 Spark 3.0 应用程序中。我尝试通过以下方式使用巴赫库:
Dataset<Row> df = sparkSession
.readStream()
.format("org.apache.bahir.sql.streaming.mqtt.MQTTStreamSourceProvider")
.option("topic", "mytopic")
.load("tcp://localhost:1883");
不幸的是,这失败了:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/spark/sql/sources/v2/StreamWriteSupport
显然这仅适用于 2.x Spark。知道如何使其与 Spark 3(或不同的库)一起使用吗?