class kafka.javaapi.consumer.SimpleConsumer {
/
Fetch a set of messages from a topic.
@param request specifies the topic name, topic partition, starting byte offset, maximum bytes to be fetched. @return a set of fetched messages
*/
public FetchResponse fetch(kafka.javaapi.FetchRequest request);
/
Fetch metadata for a sequence of topics.
@param request specifies the versionId, clientId, sequence of topics. @return metadata for each topic in the request.
/
public kafka.javaapi.TopicMetadataResponse send(kafka.javaapi.TopicMetadataRequest request);
/** Get a list of valid offsets (up to maxSize) before the given time.
@param request a [[kafka.javaapi.OffsetRequest]] object.
@return a [[kafka.javaapi.OffsetResponse]] object. /
public kafak.javaapi.OffsetResponse getOffsetsBefore(OffsetRequest request);
/* Close the SimpleConsumer.
*/
public void close();
}
对于大多数的应用,高层次的消费API是不够好的,但是一些应用需要的功能没有暴露在高层次的消费者(例如,重启消费者时,设置初始偏移量)。
这时可以使用我们低层次的SimpleCosumer Api。这个逻辑比较复杂一点,点击 这里 ,查看例子。