File tree Expand file tree Collapse file tree 5 files changed +27
-0
lines changed
java/org/woehlke/twitterwall
scheduled/mq/endoint/impl Expand file tree Collapse file tree 5 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ public class TwitterProperties {
2727 @ NotNull
2828 private Integer pageSize ;
2929
30+ @ NotNull
31+ private Integer millisToWaitBetweenTwoApiCalls ;
32+
3033 @ NotNull
3134 private String searchQuery ;
3235
@@ -77,4 +80,12 @@ public String getSearchQuery() {
7780 public void setSearchQuery (String searchQuery ) {
7881 this .searchQuery = searchQuery ;
7982 }
83+
84+ public Integer getMillisToWaitBetweenTwoApiCalls () {
85+ return millisToWaitBetweenTwoApiCalls ;
86+ }
87+
88+ public void setMillisToWaitBetweenTwoApiCalls (Integer millisToWaitBetweenTwoApiCalls ) {
89+ this .millisToWaitBetweenTwoApiCalls = millisToWaitBetweenTwoApiCalls ;
90+ }
8091}
Original file line number Diff line number Diff line change @@ -59,10 +59,15 @@ public List<TweetFromTwitter> splitMessage(Message<TaskMessage> message) {
5959 hasNext = tweetTwitterIds .hasNext ();
6060 worklistTwitterIds .addAll (tweetTwitterIds .getContent ());
6161 }
62+ int millisToWaitBetweenTwoApiCalls = twitterProperties .getMillisToWaitBetweenTwoApiCalls ();
6263 for (Long tweetTwitterId : worklistTwitterIds ){
6364 Tweet foundTweetFromTwitter = twitterApiService .findOneTweetById (tweetTwitterId );
6465 TweetFromTwitter result = new TweetFromTwitter (task .getId (),foundTweetFromTwitter );
6566 tweets .add (result );
67+ try {
68+ Thread .sleep (millisToWaitBetweenTwoApiCalls );
69+ } catch (InterruptedException e ) {
70+ }
6671 }
6772 return tweets ;
6873 }
Original file line number Diff line number Diff line change @@ -73,12 +73,17 @@ public List<TwitterProfileMessage> splitMessage(Message<TaskMessage> message) {
7373 }
7474 pageRequest = pageRequest .next ();
7575 }
76+ int millisToWaitBetweenTwoApiCalls = twitterProperties .getMillisToWaitBetweenTwoApiCalls ();
7677 for (String screenName :screenNames ){
7778 TwitterProfile userProfile = twitterApiService .getUserProfileForScreenName (screenName );
7879 if (userProfile !=null ){
7980 TwitterProfileMessage userMsg = new TwitterProfileMessage (msgIn ,userProfile );
8081 userProfileList .add (userMsg );
8182 }
83+ try {
84+ Thread .sleep (millisToWaitBetweenTwoApiCalls );
85+ } catch (InterruptedException e ) {
86+ }
8287 }
8388 return userProfileList ;
8489 }
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ public List<TwitterProfileMessage> splitMessage(Message<TaskMessage> message) {
7070 worklistProfileTwitterIds .addAll (userProfileTwitterIds .getContent ());
7171 }
7272 long number = worklistProfileTwitterIds .size ();
73+ int millisToWaitBetweenTwoApiCalls = twitterProperties .getMillisToWaitBetweenTwoApiCalls ();
7374 for (Long userProfileTwitterId :worklistProfileTwitterIds ){
7475 allLoop ++;
7576 loopId ++;
@@ -85,6 +86,10 @@ public List<TwitterProfileMessage> splitMessage(Message<TaskMessage> message) {
8586 TwitterProfileMessage userMsg = new TwitterProfileMessage (msgIn ,userProfile );
8687 userProfileList .add (userMsg );
8788 }
89+ try {
90+ Thread .sleep (millisToWaitBetweenTwoApiCalls );
91+ } catch (InterruptedException e ) {
92+ }
8893 }
8994 return userProfileList ;
9095 }
Original file line number Diff line number Diff line change @@ -66,6 +66,7 @@ twitter:
6666 # consumerSecret: ${TWITTER_CONSUMER_SECRET}
6767 pageSize : ${TWITTER_PAGE_SIZE}
6868 searchQuery : ${TWITTER_SEARCH_TERM}
69+ millisToWaitBetweenTwoApiCalls : 5000
6970twitterwall :
7071 backend :
7172 twitter :
You can’t perform that action at this time.
0 commit comments