-
Notifications
You must be signed in to change notification settings - Fork 100
Not possible to get callback on stream completion #144
Comments
What I would like to do is something like: val streamFuture = client.filterStatuses(tracks = trackTerms)(processTweet)
streamFuture.onComplete(_ => {
println("Done")
System.exit(0)
}) But this does not work, since the future that is returned is the connection future, and not the stream future. |
Hi @nilsga, What you can do is closing or replacing an existing stream on demand: have a look at this section of the documentation that shows how to do that. If this doesn't help you achieve what you are trying to do, please let us know! Cheers, |
That's true, but there are cases where the stream can fail, not related to the twitter api. For instance if the connection times out from the akka stream end, or there are errors processing the tweet itself. In these cases, it would be nice to be able to just shut down, instead of running with a halted flow. |
Interesting: I didn't think of that! At present, you cannot do it. What about having the opportunity of specifying an "ErrorHandler" to specify what the stream should behave depending on the exception thrown? |
Maybe. The reason I added this in addition to #142 was that I had a very low volume stream, and akka streams reached an idle timeout. Not sure how these low level "protocol" exceptions would propagate to the client. |
In the event of an error that causes the stream to close, it does not seem to be a way to be notified about this, e.g. to shut the application down. The actual Future of the stream is "hidden" inside the
Future[TwitterStream]
that the streaming client exposes, so the only completion one is notified about is if the initial connect succeeds or fails. Neither does it seem to be any control messages to listen to in this case.The text was updated successfully, but these errors were encountered: