// calling the listeners on each message
int numProcessingThreads = 4;
ExecutorService service = Executors.newFixedThreadPool(numProcessingThreads);
// Wrap our BasicClient with the twitter4j client
Twitter4jSitestreamClient t4jClient = new Twitter4jSitestreamClient(
client, queue, Lists.newArrayList(listener), service);
// Establish a connection
t4jClient.connect();
for (int threads = 0; threads < numProcessingThreads; threads++) {
// This must be called once per processing thread
t4jClient.process();
}
Thread.sleep(5000);
// Create a sitestream controller to issue controlstream requests
SitestreamController controller = new SitestreamController(auth);
controller.getFriends(t4jClient.getStreamId(), 12345L);
controller.addUser(t4jClient.getStreamId(), 987765L);
client.stop();
}