how to stop and kill the Twitter4j stream correctly

前端 未结 2 1684
离开以前
离开以前 2021-01-23 21:20

I try to use the Twitter4j streaming features. So my implementation is in the following class :

public class TweetsStream {

    private TwitterStream m_twitters         


        
2条回答
  •  感情败类
    2021-01-23 22:18

    I have faced the similar issue . Still any of the above solution is not working , So i did a work around for this stored the twitterStream object in a map . so i can get the same object later when i need to close the stream .

                ProfileEntity profileEntity = profileRepository.findBySocialId( twitterId+"" ) ;
                ConfigurationBuilder cb = new ConfigurationBuilder();
                cb.setDebugEnabled(true);
                cb.setOAuthConsumerKey( twitterCustomerKey );
                cb.setOAuthConsumerSecret( twitterCustomerSecret );
                cb.setOAuthAccessToken( profileEntity.getAccessToken() ) ; 
                cb.setOAuthAccessTokenSecret( profileEntity.getAccessTokenSecret() ) ; 
                twitterStream =  new TwitterStreamFactory(cb.build()).getInstance();
    
              twitterStreamMap.put( twitterId , twitterStream ) ;
    

提交回复
热议问题