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

Jiangjie Qin commented on KAFKA-2390:
-------------------------------------

[~jkreps] I share your concern of the adding complexity to the API. To explain 
the case current API does not support well, consider the following code:
{code}
...
seek(t0p0, 100);
poll();
seek(t1p0, 1000);
poll();
seek(t2p0, 1000);
poll(); // OffsetOutOfRangeException received.
...
{code}
If user configure the offset reset policy to None, with current API, user may 
not be able to tell which seek actually failed, so it is hard for user to take 
action.

The *synchronous* semantic here is not very clear. When we tell user seek() is 
a synchronous call, everyone we talked to thought it also verifies the offset. 
In fact it is synchronous in terms of setting the in memory fetch position, but 
it does not really verify the offset. The exception of seek() is *asynchronous* 
and will come later at some point.

I think the problem in above example is real. It would be nice if we can find a 
solution to that without complicating the current API. One alternative might be 
throwing a SeekException like below:
{code}
public class SeekException {
  TopicPartition topicPartition;
  long SeekedOffset;
  long LogStartingOffset;
  long LogEndOffset;
}
{code}
So user can decide what to do when got the exception.

> Seek() should take a callback.
> ------------------------------
>
>                 Key: KAFKA-2390
>                 URL: https://issues.apache.org/jira/browse/KAFKA-2390
>             Project: Kafka
>          Issue Type: Sub-task
>            Reporter: Jiangjie Qin
>            Assignee: Dong Lin
>
> Currently seek is an async call. To have the same interface as other calls 
> like commit(), seek() should take a callback. This callback will be invoked 
> if the position to seek triggers OFFSET_OUT_OF_RANGE exception from broker.



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

Reply via email to