Code Monkey home page Code Monkey logo

kafkademo's Introduction

KafkaDemo Travis Travis Travis

1.BaseApi

2.Streams 常用算子操作

3.Producer

4.Consumer

5.Connector

6.Rebalance

7.Offset

8.OffsetAtomic 避免数据丢失或重复消费

9.多线程消费

10.优雅的关闭,避免丢失数据

11.自定义分区器

12.interceptor拦截器

更新中......

重复消费的原因:
通常是因为节点故障导致。
例如当发生了JAVA垃圾回收GC时,所有的线程会在safepoint处进入"stop the world"阻塞停止状态。
当GC时间过长,worker长时间没有发出心跳,如果超出了配置的间隔期,那么kafka会认为该worker节点挂掉了,
此时consumer变回执行rebanlance操作。如果过长的gc发生在执行完业务逻辑之后,提交offset之前,
consumer便会在这个时间段执行rebanlance。此时获取的是提交之前、但是已经消费完毕的offset,便会产生所谓的重复消费。

The reasons for repeated consumption are:
It is usually caused by a node failure.
For example, when the JAVA garbage recycling GC has occurred, all threads enter the "stop the world" blocking stop state at safepoint.
When the GC is too long, the worker does not make a heartbeat for a long time, and if it goes beyond the configuration interval, then Kafka will think that the worker node is hanging off,
At this point consumer turns back to execute the rebanlance operation. If the overlong GC occurs after the execution of the business logic, before the offset is submitted,
Consumer will execute rebanlance at this time. At this point, the offset which has been submitted before, but has already been consumed, will produce so-called repeated consumption.

kafkademo's People

Contributors

huangyueranbbc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.