這是我們一直在使用它成功地過濾鳴叫:
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
queue = new LinkedBlockingQueue<Status>(1000);
_collector = collector;
StatusListener listener = new StatusListener() {
public void onStatus(Status status) {
queue.offer(status);
}
public void onDeletionNotice(StatusDeletionNotice sdn) {
}
public void onTrackLimitationNotice(int i) {
}
public void onScrubGeo(long l, long l1) {
}
public void onException(Exception e) {
}
};
TwitterStreamFactory fact = new TwitterStreamFactory(new ConfigurationBuilder().setUser(_username).setPassword(_pwd).build());
_twitterStream = fact.getInstance();
_twitterStream.addListener(listener);
_twitterStream.filter(new FilterQuery().track(TERMS_TO_TRACK).setIncludeEntities(true));
}
我們不使用流式API,因爲我們根據日期範圍和其他條件的主機只可用過濾器鳴叫在查詢API接口上。因此,我的原始問題如何集成,如果我沒有訪問狀態對象 – Joe
你可以有狀態對象只是解析Tuple對象的螺栓execute()方法是這樣的:'Status status =(Status)tuple.getValue (0);' – Orbita