[英]Stream data into Azure Databricks using Event Hubs
I want to send messages from a Twitter application to an Azure event hub. 我想将消息从Twitter应用程序发送到Azure事件中心。 However, I am getting the an error that says instead of
java.util.concurrent.ExecutorService
use java.util.concurrent.ScheduledExecutorService
. 但是,我得到一个错误,指出不是
java.util.concurrent.ExecutorService
使用java.util.concurrent.ScheduledExecutorService
。
I do not know how to create the EventHubClient.create now. 我不知道如何立即创建EventHubClient.create。 Please help.
请帮忙。
I am referring to code from the link 我指的是链接中的代码
https://docs.microsoft.com/en-us/azure/azure-databricks/databricks-stream-from-eventhubs https://docs.microsoft.com/en-us/azure/azure-databricks/databricks-stream-from-eventhubs
This is error I am getting: 这是我得到的错误:
notebook:15: error: type mismatch;
笔记本15:错误:类型不匹配; found :
java.util.concurrent.ExecutorService
required:java.util.concurrent.ScheduledExecutorService
找到:
java.util.concurrent.ExecutorService
必需:java.util.concurrent.ScheduledExecutorService
val pool = `Executors.newFixedThreadPool(1)` val eventHubClient = EventHubClient.create(connStr.toString(), pool)
Here is my code, 这是我的代码,
import java.util._
import scala.collection.JavaConverters._
import com.microsoft.azure.eventhubs._
import java.util.concurrent.{Executors, ExecutorService}
val pool: ExecutorService = Executors.newFixedThreadPool(1)
val eventHubClient = EventHubClient.create(connStr.toString(), pool)
Create a library in your Databricks workspace using the Maven coordinates com.microsoft.azure:azure-eventhubs-spark_2.11:2.3.2
or higher version. 使用Maven坐标
com.microsoft.azure:azure-eventhubs-spark_2.11:2.3.2
或更高版本在Databricks工作区中创建库。 Attach the created library to your cluster and re-attach the notebook to your cluster after it. 将创建的库连接到群集,然后将笔记本重新连接到群集。
import java.util._
import scala.collection.JavaConverters._
import com.microsoft.azure.eventhubs._
import java.util.concurrent._
//Set up Connection to Azure Event Hubs
val namespaceName = "namespaceName_of_event_hub"
val eventHubName = "Name_of_event_hub"
val sasKeyName = "your_Sas_key_name"
val sasKey = "xxxxxxxxxxxxxxxxxxxxxxx"
val connStr = new ConnectionStringBuilder()
.setNamespaceName(namespaceName)
.setEventHubName(eventHubName)
.setSasKeyName(sasKeyName)
.setSasKey(sasKey)
val pool = Executors.newFixedThreadPool(1)
val eventHubClient = EventHubClient.create(connStr.toString(), pool)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.