For IntelliJ IDEA,
Android Studio or Eclipse



.hosts(properties.getProperty(CLIENT_HOSTS, Constants.STREAM_HOST)) .endpoint(endpoint) .authentication(auth)
/** * @param tweetQueue tweet Queue. * @param hosts Hostes. * @param endpoint Endpoint. * @return Client. */ protected Client buildClient(BlockingQueue<String> tweetQueue, HttpHosts hosts, StreamingEndpoint endpoint) { Authentication authentication = new OAuth1(oAuthSettings.getConsumerKey(), oAuthSettings.getConsumerSecret(), oAuthSettings.getAccessToken(), oAuthSettings.getAccessTokenSecret()); ClientBuilder builder = new ClientBuilder() .name("Ignite-Twitter-Client") .hosts(hosts) .authentication(authentication) .endpoint(endpoint) .processor(new StringDelimitedProcessor(tweetQueue)); return builder.build(); }
public static void run(String username, String password, String account, String label, String product) throws InterruptedException { BlockingQueue<String> queue = new LinkedBlockingQueue<String>(10000); BasicAuth auth = new BasicAuth(username, password); RealTimeEnterpriseStreamingEndpoint endpoint = new RealTimeEnterpriseStreamingEndpoint(account, product, label); // Create a new BasicClient. By default gzip is enabled. Client client = new ClientBuilder() .name("PowerTrackClient-01") .hosts(Constants.ENTERPRISE_STREAM_HOST) .endpoint(endpoint) .authentication(auth) .processor(new LineStringProcessor(queue)) .build(); // Establish a connection client.connect(); // Do whatever needs to be done with messages for (int msgRead = 0; msgRead < 1000; msgRead++) { String msg = queue.take(); System.out.println(msg); } client.stop(); }
.hosts(Constants.SITESTREAM_HOST) .endpoint(endpoint) .authentication(auth)
.hosts(Constants.STREAM_HOST) .endpoint(endpoint) .authentication(auth)
.hosts(Constants.STREAM_HOST) .endpoint(endpoint) .authentication(auth)
clientBuilder.hosts(host).endpoint(streamingEndpoint); client = clientBuilder.build(); client.connect();
public static void run(String consumerKey, String consumerSecret, String token, String secret) throws InterruptedException { BlockingQueue<String> queue = new LinkedBlockingQueue<String>(10000); StatusesFilterEndpoint endpoint = new StatusesFilterEndpoint(); // add some track terms endpoint.trackTerms(Lists.newArrayList("twitterapi", "#yolo")); Authentication auth = new OAuth1(consumerKey, consumerSecret, token, secret); // Authentication auth = new BasicAuth(username, password); // Create a new BasicClient. By default gzip is enabled. Client client = new ClientBuilder() .hosts(Constants.STREAM_HOST) .endpoint(endpoint) .authentication(auth) .processor(new StringDelimitedProcessor(queue)) .build(); // Establish a connection client.connect(); // Do whatever needs to be done with messages for (int msgRead = 0; msgRead < 1000; msgRead++) { String msg = queue.take(); System.out.println(msg); } client.stop(); }