{"id":20578761,"url":"https://github.com/cclient/spark-streaming-kafka-offset-mysql","last_synced_at":"2025-08-23T04:12:48.437Z","repository":{"id":93977652,"uuid":"173411900","full_name":"cclient/spark-streaming-kafka-offset-mysql","owner":"cclient","description":"mysql 维护 kafka offset,支持追踪并回滚到某个'异常'时间点，重新消费","archived":false,"fork":false,"pushed_at":"2019-03-13T12:37:50.000Z","size":7,"stargazers_count":4,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-06T18:03:08.303Z","etag":null,"topics":["mysql","offset","spark","spark-streaming"],"latest_commit_sha":null,"homepage":"https://www.cnblogs.com/zihunqingxin/p/14476970.html","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cclient.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-03-02T06:26:16.000Z","updated_at":"2023-06-30T02:31:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"f64f035b-028a-4315-bfcf-2070023e595a","html_url":"https://github.com/cclient/spark-streaming-kafka-offset-mysql","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cclient/spark-streaming-kafka-offset-mysql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cclient%2Fspark-streaming-kafka-offset-mysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cclient%2Fspark-streaming-kafka-offset-mysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cclient%2Fspark-streaming-kafka-offset-mysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cclient%2Fspark-streaming-kafka-offset-mysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cclient","download_url":"https://codeload.github.com/cclient/spark-streaming-kafka-offset-mysql/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cclient%2Fspark-streaming-kafka-offset-mysql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271740731,"owners_count":24812642,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mysql","offset","spark","spark-streaming"],"created_at":"2024-11-16T06:14:29.823Z","updated_at":"2025-08-23T04:12:48.425Z","avatar_url":"https://github.com/cclient.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"### use Spark SQL to load/store offset with mysql\n\nless complicated than custom implement sql operation\n\n#### offset store\n\n```sql\nmysql\u003e select * from kfk_offset where datetime\u003e'2019-01-09' and topic='task-response' and `group`='extract';\n+--------+------------+-------+------+-----------+-----------+-----------+-------+---------------------+\n| id     | topic      | group | step | partition | from      | until     | count | datetime            |\n+--------+------------+-------+------+-----------+-----------+-----------+-------+---------------------+\n| 1 | task-response | extract   |  1 |         0 | 1959008 | 1995008 | 36000 | 2019-01-09 00:01:19 |\n| 2 | task-response | extract   |  1 |         1 | 1897546 | 1933546 | 36000 | 2019-01-09 00:01:19 |\n| 0 | task-response | extract   |  1 |         2 | 1876072 | 1912072 | 36000 | 2019-01-09 00:01:19 |\n| 5 | task-response | extract   |  2 |         0 | 1995008 | 2031008 | 36000 | 2019-01-09 00:05:05 |\n| 7 | task-response | extract   |  2 |         1 | 1933546 | 1969546 | 36000 | 2019-01-09 00:05:05 |\n| 6 | task-response | extract   |  2 |         2 | 1912072 | 1948072 | 36000 | 2019-01-09 00:05:05 |\n\n```\n\nFor my scene(extract crawler's response dom/json),I need rollback to the 'problem datetime' and re-consumer records after it;\n\n### rollback\n \n1 kill the spark consume process\n\n2 point the problem datetime,then delete sql record by datetime or step \n\n`delete from kfk_offset where `step`\u003e1 and `topic`='task-response' and `group`='extract'`\n\n3 start the spark consume process\n\n### Use \n\n#### develop \n\ncopy source code\n\nor\n\ncopy spark-streaming-kafka-offset-mysql_2.11-0.1.jar -\u003e {project}/lib/\n\n#### deploy\n\nsbt package\n\ncopy spark-streaming-kafka-offset-mysql_2.11-0.1.jar -\u003e $SPARK_HOME/jars/\n\n### other\n\nupload to maven repositories to use jar ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcclient%2Fspark-streaming-kafka-offset-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcclient%2Fspark-streaming-kafka-offset-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcclient%2Fspark-streaming-kafka-offset-mysql/lists"}