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

ASF GitHub Bot commented on KAFKA-2478:
---------------------------------------

GitHub user shtratos opened a pull request:

    https://github.com/apache/kafka/pull/210

    KAFKA-2478: Fix manual committing example in javadoc

    Committing before inserting all records into the database
    might lead to some records being lost.
    
    I've changed the example to commit only after all records 
    returned by `poll` are inserted into the database.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/shtratos/kafka KAFKA-2478

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/kafka/pull/210.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #210
    
----
commit 7d1104e8313da3aabb291e9d90a55b07c35f7419
Author: Dmitry Stratiychuk <dstratiyc...@yammer-inc.com>
Date:   2015-09-13T21:51:20Z

    KAFKA-2478: Fix manual committing example in javadoc
    
    Committing before inserting all records into the database
    might lead to some records being lost.

commit fd74eb8e497cc87b1bb7f2c53a466b2e5fe8a6fa
Author: Dmitry Stratiychuk <dstratiyc...@yammer-inc.com>
Date:   2015-09-13T21:54:32Z

    TRIVIAL: use diamond operator <> where possible

commit 454098a50abb24e35f93683638530253eb9ae801
Author: Dmitry Stratiychuk <dstratiyc...@yammer-inc.com>
Date:   2015-09-13T22:02:22Z

    KAFKA-2478: Fix invocations of `subscribe` in javadoc examples
    
    `subscribe` method now accepts list of topic names.

commit 20f3c40185e8d4bc8010d69f1801384846a7942f
Author: Dmitry Stratiychuk <dstratiyc...@yammer-inc.com>
Date:   2015-09-13T22:13:47Z

    KAFKA-2478: Fix invocations of `assign` in javadoc examples
    
    `assign` method now accepts a list of `TopicPartition`s.

----


> KafkaConsumer javadoc example seems wrong
> -----------------------------------------
>
>                 Key: KAFKA-2478
>                 URL: https://issues.apache.org/jira/browse/KAFKA-2478
>             Project: Kafka
>          Issue Type: Bug
>          Components: consumer
>    Affects Versions: 0.9.0.0
>            Reporter: Dmitry Stratiychuk
>            Assignee: Neha Narkhede
>
> I was looking at this KafkaConsumer example in the javadoc:
> https://github.com/apache/kafka/blob/trunk/clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java#L199
> As I understand, commit() method commits the maximum offsets returned by the 
> most recent invocation of poll() method.
> In this example, there's a danger of losing the data.
> Imagine the case where 300 records are returned by consumer.poll()
> The commit will happen after inserting 200 records into the database.
> But it will also commit the offsets for 100 records that are still 
> unprocessed.
> So if consumer fails before buffer is dumped into the database again,
> then those 100 records will never be processed.
> If I'm wrong, could you please clarify the behaviour of commit() method?



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

Reply via email to