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.
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.
val queryListener: StreamingQueryListener = ...
spark.streams.addListener(queryListener)
You can remove a StreamingQueryListener
using StreamingQueryManager.removeListener method.
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 |