Ewen Cheslack-Postava created KAFKA-1780:
--------------------------------------------

             Summary: Add peek()/poll() for ConsumerIterator
                 Key: KAFKA-1780
                 URL: https://issues.apache.org/jira/browse/KAFKA-1780
             Project: Kafka
          Issue Type: Bug
          Components: consumer
    Affects Versions: 0.8.1.1
            Reporter: Ewen Cheslack-Postava
            Assignee: Ewen Cheslack-Postava


Currently, all consumer operations (next(), haveNext()) block. This is 
problematic for a couple of use cases. Most obviously, a peek() method would be 
nice so you can at least check whether any data is immediately available, 
getting a null value back if it's not.

A more difficult example is a proxy with a timeout, i.e. it consumes messages 
for up to N ms or M messages, and returns whatever it has at the end of that 
period. It's possible to approximate that with peek, but requires aggressive 
polling to match the proxy's timeout. A poll(timeout) method would allow for a 
correct implementation, where each call to poll gets a single message, but also 
allows the user to specify a custom timeout.



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

Reply via email to