Hi all,

I'm using Kafka low level consumer api and find in the below codes
"iterator.hasNext" always return false. Through debugging, I'm sure the
messageSet has the size of "fetchSize"

*     val consumer = new SimpleConsumer(broker.host, broker.port,
soTimeout, soBufferSize, clientId)*
*      val request = new FetchRequestBuilder()*
*        .addFetch(topic, partition, offset, fetchSize)*
*        .build()*
*      val response = consumer.fetch(request)*
*      response.errorCode(topic, partition) match {*
*        case NoError => {*
*          iterator = response.messageSet(topic, partition).iterator*
*        }*
*        case error => throw exceptionFor(error)*
*     }*

The weird thing is that the iterator works fine when I get iterator
directly without checking the error code.

*     val consumer = new SimpleConsumer(broker.host, broker.port,
soTimeout, soBufferSize, clientId)*
*      val request = new FetchRequestBuilder()*
*        .addFetch(topic, partition, offset, fetchSize)*
*        .build()*
*       consumer.fetch(request).messageSet(topic, partition).iterator*

Any thoughts ?

Thanks,
Manu Zhang

Reply via email to