Stop streaming context in Spark Streaming after a period of time
You can use the awaitTermination()
method on the streamingContext
object to wait for a specified time. Refer this
You can use either
awaitTerminationOrTimeout(long)
as mentioned in the previous answer, or you can stop the streaming context manually from your other thread:
// in the main thread
awaitTermination(); // will wait forever or until the context is stopped
// in another thread
streamingContext.stop();