我一直在尝试建立概念证明,Azure Databricks使用以下代码从事件中心读取数据:
connectionString = "sb://mystream.servicebus.windows.net/theeventhub;EntityPath=theeventhub;SharedAccessKeyName=event_test;SharedAccessKey=mykeygoeshere12345"
ehConf = {
'eventhubs.connectionString' : connectionString
}
df = spark \
.readStream \
.format("eventhubs") \
.options(**ehConf) \
.load()
readEventStream = df.withColumn("body", df["body"].cast("string"))
display(readEventStream)
我正在使用azure_eventhubs_spark_2_11_2_3_6.jar包作为推荐的here,但我已经尝试了最新版本并不断收到消息
ERROR : Some streams terminated before this command could finish!
我使用了databricks运行时版本6.1,并将其回滚到5.3,但似乎无法启动并运行它。我有一个将数据发送到事件中心的Python脚本,我只是看不到任何东西吗?是包装吗?还是我做错了什么?
它与以下配置完美配合:
Databrick运行时: 5.5 LTS(包括Apache Spark 2.4.3,Scala 2.11)
Azure EventHub库: com.microsoft.azure:azure-eventhubs-spark_2.11:2.3.13
使用上面的配置,能够从Azure Eventhubs中获取流数据。
参考: Integrating Apache Spark with Azure Event Hubs
希望这会有所帮助。