I try to use the Twitter4j streaming features. So my implementation is in the following class :
public class TweetsStream {
private TwitterStream m_twitters
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 ) ;