How to Apply window function while reading data from Azure EventHub

I'm currently reading streaming data from Azure EventHub with the below code, i will need to apply some window function so to read records for some 5 mints and parse it. Is there a window function available so to read the records for only 5 mints.

Below is the code i'm currently running:

val namespaceName = "XXXXX"
val eventHubName = "XXXXX"
val sasKeyName = "XXXXXX"
val sasKey = "XXXXXX"

val connStr = new

val customEventhubParameters = EventHubsConf(connStr.toString()).setMaxEventsPerTrigger(5)

 // Create a stream that reads data from the specified Event Hub.
val incomingStream = spark.readStream.format("eventhubs").options(customEventhubParameters.toMap).load()

val messages = incomingStream.withColumn("Offset", $"offset".cast(LongType)).withColumn("Time (readable)", $"enqueuedTime".cast(TimestampType)).withColumn("Timestamp", $"enqueuedTime".cast(LongType)).withColumn("Body", $"body".cast(StringType)).select("Offset", "Time (readable)", "Timestamp", "Body")


 |-- Offset: long (nullable = true)
 |-- Time (readable): timestamp (nullable = true)
 |-- Timestamp: long (nullable = true)
 |-- Body: string (nullable = true)

 messages.writeStream.outputMode("append").format("console").option("truncate", false).start()

Above code will start streaming continuously, but i need only 5 mints of data to parse further, is there a window function so to read only 5 mints of data from Azure EventHub. Any help would be much appreciated.