Did you get any error code in the response? Also, make sure fetchSize is
larger than the largest single message.

Thanks,

Jun

On Sun, Jan 18, 2015 at 4:54 PM, Manu Zhang <[email protected]> wrote:

> 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