[ 
https://issues.apache.org/jira/browse/KAFKA-1956?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14322592#comment-14322592
 ] 

Hongliang Su commented on KAFKA-1956:
-------------------------------------

[~jkreps]   
I understood what you mean. User should use one loop with the "poll" to get the 
records.

my client code as follows:
{code}
rt = this.consumer.poll(10000);

if (rt != null && rt.count() > 0) {
        
        Iterable<ConsumerRecord<String, String>> iter = rt.records(tp);
        
        for (ConsumerRecord<String, String> rec : iter) {
                
                try {
                        System.out.println("consumer: " + rec.topic()
                                        + " " + rec.offset() + " "
                                        + rec.partition() + " " + rec.key()
                                        + " " + rec.value());
                } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }

        i += rt.count();
}
{code}

Even I set the timeout as long enough, there has no records returned.
And in my opinion, messages exists on the subscribed partitions, and I invoked 
the "poll", the records should be returned. 


And I tried your client loop code, it really works. 

> new consumer client can't fetch records from kafka server
> ---------------------------------------------------------
>
>                 Key: KAFKA-1956
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1956
>             Project: Kafka
>          Issue Type: Bug
>          Components: clients, consumer
>    Affects Versions: 0.8.3
>            Reporter: Hongliang Su
>            Assignee: Neha Narkhede
>              Labels: patch
>         Attachments: 
> 0005-fix-new-consumer-client-can-t-fetch-records-from-kaf.patch
>
>   Original Estimate: 12h
>  Remaining Estimate: 12h
>
> new consumer client can't fetch records from kafka server
> suggestion:
> fetch response doesn't return even after one completeAll invoke
> block until the fetch response returns
> TODO: whether there is an effective way to wait until fetch response returns



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to