.name(properties.getProperty(CLIENT_NAME, "flink-twitter-source")) .hosts(properties.getProperty(CLIENT_HOSTS, Constants.STREAM_HOST)) .endpoint(endpoint)
clientBuilder.name("GetTwitter[id=" + getIdentifier() + "]") .authentication(oauth) .eventMessageQueue(eventQueue)
/** * @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(); }
.name("sampleExampleClient") .hosts(Constants.STREAM_HOST) .endpoint(endpoint)
private Client getTwitterClient(Properties props, BlockingQueue<String> messageQueue) { String clientName = props.getProperty("clientName"); String consumerKey = props.getProperty("consumerKey"); String consumerSecret = props.getProperty("consumerSecret"); String token = props.getProperty("token"); String tokenSecret = props.getProperty("tokenSecret"); List<String> searchTerms = Arrays.asList(props.getProperty("searchTerms").split(",")); Authentication authentication = new OAuth1(consumerKey,consumerSecret,token,tokenSecret); Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST); StatusesFilterEndpoint hosebirdEndpoint = new StatusesFilterEndpoint(); hosebirdEndpoint.trackTerms(searchTerms); ClientBuilder clientBuilder = new ClientBuilder(); clientBuilder.name(clientName) .hosts(hosebirdHosts) .authentication(authentication) .endpoint(hosebirdEndpoint) .processor(new StringDelimitedProcessor(messageQueue)); return clientBuilder.build(); }
.name(properties.getProperty(CLIENT_NAME, "flink-twitter-source")) .hosts(properties.getProperty(CLIENT_HOSTS, Constants.STREAM_HOST)) .endpoint(endpoint)
.name(config.getClientName()) .hosts(config.getClientHosts()) .endpoint(new SampleStatusesEndpoint().createEndpoint())
clientBuilder.name("bbejeck-hosebird") .hosts(hosebirdHosts) .authentication(hosebirdAuth)
clientBuilder.name("GetTwitter[id=" + getIdentifier() + "]") .authentication(oauth) .eventMessageQueue(eventQueue)
public Client createTwitterClient(BlockingQueue<String> msgQueue){ /** Declare the host you want to connect to, the endpoint, and authentication (basic auth or oauth) */ Hosts hosebirdHosts = new HttpHosts(Constants.STREAM_HOST); StatusesFilterEndpoint hosebirdEndpoint = new StatusesFilterEndpoint(); hosebirdEndpoint.trackTerms(terms); // These secrets should be read from a config file Authentication hosebirdAuth = new OAuth1(consumerKey, consumerSecret, token, secret); ClientBuilder builder = new ClientBuilder() .name("Hosebird-Client-01") // optional: mainly for the logs .hosts(hosebirdHosts) .authentication(hosebirdAuth) .endpoint(hosebirdEndpoint) .processor(new StringDelimitedProcessor(msgQueue)); Client hosebirdClient = builder.build(); return hosebirdClient; }