I try to use the Twitter4j streaming features. So my implementation is in the following class :
public class TweetsStream {
private TwitterStream m_twitters
Here's the solution :
The method TwitterStreamFactory.getSingleton()
returns the same instance of the TwitterStream.
Even if you delete properly your TwitterStream object, the listeners are stored in your TwitterStream Singleton config... So you have to create differents instances of the TwitterStream object with :
TwitterStreamFactory l_Twitterfactory = new TwitterStreamFactory();
m_twitterstream = l_Twitterfactory.getInstance();
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 ) ;