StreamingQueryListener — Intercepting Streaming Events
StreamingQueryListener
is the contract for listeners that want to be notified about the life cycle events of streaming queries, i.e. start, progress and termination of a query.
1 2 3 4 5 6 7 8 9 10 11 |
package org.apache.spark.sql.streaming abstract class StreamingQueryListener { def onQueryStarted(event: QueryStartedEvent): Unit def onQueryProgress(event: QueryProgressEvent): Unit def onQueryTerminated(event: QueryTerminatedEvent): Unit } |
Event | Callback | When Posted |
---|---|---|
|
Right after |
|
|
|
|
|
Right before |
You can register a StreamingQueryListener
using StreamingQueryManager.addListener method.
1 2 3 4 5 6 |
val queryListener: StreamingQueryListener = ... spark.streams.addListener(queryListener) |
You can remove a StreamingQueryListener
using StreamingQueryManager.removeListener method.
1 2 3 4 5 6 |
val queryListener: StreamingQueryListener = ... spark.streams.removeListener(queryListener) |
Note
|
onQueryStarted is used internally to unblock the starting thread of StreamExecution .
|
Note
|
You can also register a streaming event listener using the general Details on |