我使用kafka
API从createDirectStream()
使用数据。我想catch
ClosedChannelException
并处理与zookeeper
和kafka主题的断开连接。
通过测试,我只能这样做:
try { myStreamingContext.awaitTermination }
catch { case foo:SparkException => if (foo.getMessage contains """ClosedChannelException""") /*do something*/ }
看起来例外只是" catchable"与上述相符,或者至少不符合我预期的try { val stream = createDirectStream([...]) } [...]
。
是否有任何方法可以处理这个(和其他连接错误)应用程序端?