Apache spark 如何使用spark eventhubs从事件中获取偏移量/序列号

Apache spark 如何使用spark eventhubs从事件中获取偏移量/序列号,apache-spark,spark-streaming,azure-eventhub,Apache Spark,Spark Streaming,Azure Eventhub,从代码开始,我们可以使用新字符串(x)获取事件的主体部分,因为x是作为字节数组传递给我们的。在使用此spark eventhubs库时,是否仍然可以获取事件数据的系统属性?我想要有关序列号/偏移量或事件在此事件中心排队的时间的信息。使用DirectStreams API直接公开事件数据 val inputDirectStream = EventHubsUtils.createDirectStreams( ssc, eventHubNamespace, prog

从代码开始,我们可以使用新字符串(x)获取事件的主体部分,因为x是作为字节数组传递给我们的。在使用此spark eventhubs库时,是否仍然可以获取事件数据的系统属性?我想要有关序列号/偏移量或事件在此事件中心排队的时间的信息。

使用DirectStreams API直接公开
事件数据
val inputDirectStream = EventHubsUtils.createDirectStreams(
      ssc,
      eventHubNamespace,
      progressDir,
      Map(eventHubName -> eventhubParameters))

inputDirectStream.foreachRDD { rdd =>
      rdd.flatMap(eventData => new String(eventData.getBody).split(" ").map(_.replaceAll(
        "[^A-Za-z0-9 ]", ""))).map(word => (word, 1)).reduceByKey(_ + _).collect().toList.
       foreach(println)
    }

// all you need here is eventData.getSystemProperties.getSequenceNumber