File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed
examples/src/main/java/com/twitter/clientlib Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ public static void main(String[] args) {
5252 }
5353
5454 if (tsle .getError () != null ) {
55- System .err .println ("==> Finished " + tsle .getError ());
55+ System .err .println ("==> Ended with error: " + tsle .getError ());
5656 }
5757
5858// // Shutdown TweetsStreamListenersExecutor
Original file line number Diff line number Diff line change 3535public class TweetsStreamListenersExecutor {
3636 private final static int TIMEOUT_MILLIS = 60000 ;
3737 private final static int SLEEP_MILLIS = 100 ;
38+ private final static int BACKOFF_SLEEP_INTERVAL_MILLIS = 5000 ;
3839 private TweetsQueuer tweetsQueuer ;
3940 private ITweetsQueue tweetsQueue = new LinkedListTweetsQueue ();
4041 private final AtomicBoolean isRunning = new AtomicBoolean (true );
4142 private final AtomicLong tweetStreamedTime = new AtomicLong (0 );
4243 private Exception caughtException ;
4344 private IStreamingHandler <?> streamingHandler ;
45+ private long reconnecting = 0 ;
4446
4547 public StreamListenersExecutorBuilder stream () {
4648 return new StreamListenersExecutorBuilder ();
@@ -75,8 +77,12 @@ private boolean isTweetStreamedError() {
7577
7678 private void restartTweetsQueuer () {
7779 tweetsQueuer .shutdownQueuer ();
80+ if (reconnecting < 7 ) {
81+ reconnecting ++;
82+ }
7883 try {
79- Thread .sleep (SLEEP_MILLIS ); // Wait a bit before starting the TweetsQueuer and calling the API again.
84+ System .out .println ("sleeping " + BACKOFF_SLEEP_INTERVAL_MILLIS * reconnecting );
85+ Thread .sleep (BACKOFF_SLEEP_INTERVAL_MILLIS * reconnecting ); // Wait a bit before starting the TweetsQueuer and calling the API again.
8086 } catch (InterruptedException e ) {
8187 e .printStackTrace ();
8288 }
You can’t perform that action at this time.
0 commit comments