{"id":13470747,"url":"https://github.com/apache/kafka","last_synced_at":"2025-11-12T21:42:49.441Z","repository":{"id":37224125,"uuid":"2211243","full_name":"apache/kafka","owner":"apache","description":"Mirror of Apache Kafka","archived":false,"fork":false,"pushed_at":"2025-05-12T15:08:28.000Z","size":245252,"stargazers_count":30063,"open_issues_count":250,"forks_count":14363,"subscribers_count":1054,"default_branch":"trunk","last_synced_at":"2025-05-12T16:24:39.892Z","etag":null,"topics":["kafka","scala"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/apache.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"docs/security.html","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2011-08-15T18:06:16.000Z","updated_at":"2025-05-12T15:59:01.000Z","dependencies_parsed_at":"2023-09-26T17:00:50.870Z","dependency_job_id":"b3791400-fa1d-4edc-8cbc-85d27e9d8ed9","html_url":"https://github.com/apache/kafka","commit_stats":{"total_commits":14665,"total_committers":1358,"mean_commits":10.79896907216495,"dds":0.952744630071599,"last_synced_commit":"5684fc7a2ee1a4f29cb6d69d713233ed3c297882"},"previous_names":[],"tags_count":267,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fkafka","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fkafka/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fkafka/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apache%2Fkafka/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apache","download_url":"https://codeload.github.com/apache/kafka/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253783456,"owners_count":21963889,"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","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":["kafka","scala"],"created_at":"2024-07-31T16:00:35.439Z","updated_at":"2025-11-12T21:42:49.435Z","avatar_url":"https://github.com/apache.png","language":"Java","readme":"\u003cp align=\"center\"\u003e\n\u003cpicture\u003e\n  \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"docs/images/kafka-logo-readme-light.svg\"\u003e\n  \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"docs/images/kafka-logo-readme-dark.svg\"\u003e\n  \u003cimg src=\"docs/images/kafka-logo-readme-light.svg\" alt=\"Kafka Logo\" width=\"50%\"\u003e \n\u003c/picture\u003e\n\u003c/p\u003e\n\n[![CI](https://github.com/apache/kafka/actions/workflows/ci.yml/badge.svg?branch=trunk\u0026event=push)](https://github.com/apache/kafka/actions/workflows/ci.yml?query=event%3Apush+branch%3Atrunk)\n[![Flaky Test Report](https://github.com/apache/kafka/actions/workflows/generate-reports.yml/badge.svg?branch=trunk\u0026event=schedule)](https://github.com/apache/kafka/actions/workflows/generate-reports.yml?query=event%3Aschedule+branch%3Atrunk)\n\n[**Apache Kafka**](https://kafka.apache.org) is an open-source distributed event streaming platform used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications.\n\nYou need to have [Java](http://www.oracle.com/technetwork/java/javase/downloads/index.html) installed.\n\nWe build and test Apache Kafka with 17 and 25. The `release` parameter in javac is set to `11` for the clients \nand streams modules, and `17` for the rest, ensuring compatibility with their respective\nminimum Java versions. Similarly, the `release` parameter in scalac is set to `11` for the streams modules and `17`\nfor the rest.\n\nScala 2.13 is the only supported version in Apache Kafka.\n\n### Build a jar and run it ###\n    ./gradlew jar\n\nFollow instructions in https://kafka.apache.org/quickstart\n\n### Build source jar ###\n    ./gradlew srcJar\n\n### Build aggregated javadoc ###\n    ./gradlew aggregatedJavadoc --no-parallel\n\n### Build javadoc and scaladoc ###\n    ./gradlew javadoc\n    ./gradlew javadocJar # builds a javadoc jar for each module\n    ./gradlew scaladoc\n    ./gradlew scaladocJar # builds a scaladoc jar for each module\n    ./gradlew docsJar # builds both (if applicable) javadoc and scaladoc jars for each module\n\n### Run unit/integration tests ###\n    ./gradlew test  # runs both unit and integration tests\n    ./gradlew unitTest\n    ./gradlew integrationTest\n    ./gradlew test -Pkafka.test.run.flaky=true  # runs tests that are marked as flaky\n\n    \n### Force re-running tests without code change ###\n    ./gradlew test --rerun-tasks\n    ./gradlew unitTest --rerun-tasks\n    ./gradlew integrationTest --rerun-tasks\n\n### Running a particular unit/integration test ###\n    ./gradlew clients:test --tests RequestResponseTest\n    ./gradlew streams:integration-tests:test --tests RestoreIntegrationTest\n\n### Repeatedly running a particular unit/integration test with specific times by setting N ###\n    N=500; I=0; while [ $I -lt $N ] \u0026\u0026 ./gradlew clients:test --tests RequestResponseTest --rerun --fail-fast; do (( I=$I+1 )); echo \"Completed run: $I\"; sleep 1; done\n\n### Running a particular test method within a unit/integration test ###\n    ./gradlew core:test --tests kafka.api.ProducerFailureHandlingTest.testCannotSendToInternalTopic\n    ./gradlew clients:test --tests org.apache.kafka.clients.MetadataTest.testTimeToNextUpdate\n    ./gradlew streams:integration-tests:test --tests org.apache.kafka.streams.integration.RestoreIntegrationTest.shouldRestoreNullRecord\n\n### Running a particular unit/integration test with log4j output ###\nBy default, there will be only small number of logs output while testing. You can adjust it by changing the `log4j2.yaml` file in the module's `src/test/resources` directory.\n\nFor example, if you want to see more logs for clients project tests, you can modify [the line](https://github.com/apache/kafka/blob/trunk/clients/src/test/resources/log4j2.yaml#L35) in `clients/src/test/resources/log4j2.yaml` \nto `level: INFO` and then run:\n    \n    ./gradlew cleanTest clients:test --tests NetworkClientTest   \n\nAnd you should see `INFO` level logs in the file under the `clients/build/test-results/test` directory.\n\n### Specifying test retries ###\nRetries are disabled by default, but you can set maxTestRetryFailures and maxTestRetries to enable retries.\n\nThe following example declares -PmaxTestRetries=1 and -PmaxTestRetryFailures=3 to enable a failed test to be retried once, with a total retry limit of 3.\n\n    ./gradlew test -PmaxTestRetries=1 -PmaxTestRetryFailures=3\n\nSee [Test Retry Gradle Plugin](https://github.com/gradle/test-retry-gradle-plugin) and [build.yml](.github/workflows/build.yml) for more details.\n\n### Generating test coverage reports ###\nGenerate coverage reports for the whole project:\n\n    ./gradlew reportCoverage -PenableTestCoverage=true -Dorg.gradle.parallel=false\n\nGenerate coverage for a single module, i.e.: \n\n    ./gradlew clients:reportCoverage -PenableTestCoverage=true -Dorg.gradle.parallel=false\n\nCoverage reports are located within the module's build directory, categorized by module type:\n\nCore Module (:core): `core/build/reports/scoverageTest/index.html`\n\nOther Modules: `\u003cmodule\u003e/build/reports/jacoco/test/html/index.html`\n\n### Building a binary release gzipped tar ball ###\n    ./gradlew clean releaseTarGz\n\nThe release file can be found inside `./core/build/distributions/`.\n\n### Building auto generated messages ###\nSometimes it is only necessary to rebuild the RPC auto-generated message data when switching between branches, as they could\nfail due to code changes. You can just run:\n \n    ./gradlew processMessages processTestMessages\n\nSee [Apache Kafka Message Definitions](clients/src/main/resources/common/message/README.md) for details on Apache Kafka message protocol.\n\n### Running a Kafka broker\n\nUsing compiled files:\n\n    KAFKA_CLUSTER_ID=\"$(./bin/kafka-storage.sh random-uuid)\"\n    ./bin/kafka-storage.sh format --standalone -t $KAFKA_CLUSTER_ID -c config/server.properties\n    ./bin/kafka-server-start.sh config/server.properties\n\nUsing docker image:\n\n    docker run -p 9092:9092 apache/kafka:latest\n\nSee [docker/README.md](docker/README.md) for detailed information.\n\n### Cleaning the build ###\n    ./gradlew clean\n\n### Running a task for a specific project ###\nThis is for `core`, `examples` and `clients`\n\n    ./gradlew core:jar\n    ./gradlew core:test\n\nStreams has multiple sub-projects, but you can run all the tests:\n\n    ./gradlew :streams:testAll\n\n### Listing all gradle tasks ###\n    ./gradlew tasks\n\n### Building IDE project ####\n*Note Please ensure that JDK17 is used when developing Kafka.*\n\nIntelliJ supports Gradle natively and it will automatically check Java syntax and compatibility for each module, even if\nthe Java version shown in the `Structure \u003e Project Settings \u003e Modules` may not be the correct one.\n\nWhen it comes to Eclipse, run:\n\n    ./gradlew eclipse\n\nThe `eclipse` task has been configured to use `${project_dir}/build_eclipse` as Eclipse's build directory. Eclipse's default\nbuild directory (`${project_dir}/bin`) clashes with Kafka's scripts directory and we don't use Gradle's build directory\nto avoid known issues with this configuration.\n\n### Publishing the streams quickstart archetype artifact to maven ###\nFor the Streams archetype project, one cannot use gradle to upload to maven; instead the `mvn deploy` command needs to be called at the quickstart folder:\n\n    cd streams/quickstart\n    mvn deploy\n\nPlease note for this to work you should create/update user maven settings (typically, `${USER_HOME}/.m2/settings.xml`) to assign the following variables\n\n    \u003csettings xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\"\n       xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n       xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0\n                           https://maven.apache.org/xsd/settings-1.0.0.xsd\"\u003e\n    ...                           \n    \u003cservers\u003e\n       ...\n       \u003cserver\u003e\n          \u003cid\u003eapache.snapshots.https\u003c/id\u003e\n          \u003cusername\u003e${maven_username}\u003c/username\u003e\n          \u003cpassword\u003e${maven_password}\u003c/password\u003e\n       \u003c/server\u003e\n       \u003cserver\u003e\n          \u003cid\u003eapache.releases.https\u003c/id\u003e\n          \u003cusername\u003e${maven_username}\u003c/username\u003e\n          \u003cpassword\u003e${maven_password}\u003c/password\u003e\n        \u003c/server\u003e\n        ...\n     \u003c/servers\u003e\n     ...\n\n### Installing all projects to the local Maven repository ###\n\n    ./gradlew -PskipSigning=true publishToMavenLocal\n\n### Installing specific projects to the local Maven repository ###\n\n    ./gradlew -PskipSigning=true :streams:publishToMavenLocal\n    \n### Building the test jar ###\n    ./gradlew testJar\n\n### Running code quality checks ###\nThere are two code quality analysis tools that we regularly run, spotbugs and checkstyle.\n\n#### Checkstyle ####\nCheckstyle enforces a consistent coding style in Kafka.\nYou can run checkstyle using:\n\n    ./gradlew checkstyleMain checkstyleTest spotlessCheck\n\nThe checkstyle warnings will be found in `reports/checkstyle/reports/main.html` and `reports/checkstyle/reports/test.html` files in the\nsubproject build directories. They are also printed to the console. The build will fail if Checkstyle fails.\nFor experiments (or regression testing purposes) add `-PcheckstyleVersion=X.y.z` switch (to override project-defined checkstyle version).\n\n#### Spotless ####\nThe import order is a part of static check. please call `spotlessApply` to optimize the imports of Java codes before filing pull request.\n\n    ./gradlew spotlessApply\n\n#### Spotbugs ####\nSpotbugs uses static analysis to look for bugs in the code.\nYou can run spotbugs using:\n\n    ./gradlew spotbugsMain spotbugsTest -x test\n\nThe spotbugs warnings will be found in `reports/spotbugs/main.html` and `reports/spotbugs/test.html` files in the subproject build\ndirectories.  Use -PxmlSpotBugsReport=true to generate an XML report instead of an HTML one.\n\n### JMH microbenchmarks ###\nWe use [JMH](https://openjdk.java.net/projects/code-tools/jmh/) to write microbenchmarks that produce reliable results in the JVM.\n    \nSee [jmh-benchmarks/README.md](https://github.com/apache/kafka/blob/trunk/jmh-benchmarks/README.md) for details on how to run the microbenchmarks.\n\n### Dependency Analysis ###\n\nThe gradle [dependency debugging documentation](https://docs.gradle.org/current/userguide/viewing_debugging_dependencies.html) mentions using the `dependencies` or `dependencyInsight` tasks to debug dependencies for the root project or individual subprojects.\n\nAlternatively, use the `allDeps` or `allDepInsight` tasks for recursively iterating through all subprojects:\n\n    ./gradlew allDeps\n\n    ./gradlew allDepInsight --configuration runtimeClasspath --dependency com.fasterxml.jackson.core:jackson-databind\n\nThese take the same arguments as the builtin variants.\n\n### Determining if any dependencies could be updated ###\n    ./gradlew dependencyUpdates --no-parallel\n\n### Common build options ###\n\nThe following options should be set with a `-P` switch, for example `./gradlew -PmaxParallelForks=1 test`.\n\n* `commitId`: sets the build commit ID as .git/HEAD might not be correct if there are local commits added for build purposes.\n* `mavenUrl`: sets the URL of the maven deployment repository (`file://path/to/repo` can be used to point to a local repository).\n* `maxParallelForks`: maximum number of test processes to start in parallel. Defaults to the number of processors available to the JVM.\n* `maxScalacThreads`: maximum number of worker threads for the scalac backend. Defaults to the lowest of `8` and the number of processors\navailable to the JVM. The value must be between 1 and 16 (inclusive). \n* `ignoreFailures`: ignore test failures from junit\n* `showStandardStreams`: shows standard out and standard error of the test JVM(s) on the console.\n* `skipSigning`: skips signing of artifacts.\n* `testLoggingEvents`: unit test events to be logged, separated by comma. For example `./gradlew -PtestLoggingEvents=started,passed,skipped,failed test`.\n* `xmlSpotBugsReport`: enable XML reports for spotBugs. This also disables HTML reports as only one can be enabled at a time.\n* `maxTestRetries`: maximum number of retries for a failing test case.\n* `maxTestRetryFailures`: maximum number of test failures before retrying is disabled for subsequent tests.\n* `enableTestCoverage`: enables test coverage plugins and tasks, including bytecode enhancement of classes required to track said\ncoverage. Note that this introduces some overhead when running tests and hence why it's disabled by default (the overhead\nvaries, but 15-20% is a reasonable estimate).\n* `keepAliveMode`: configures the keep alive mode for the Gradle compilation daemon - reuse improves start-up time. The values should \nbe one of `daemon` or `session` (the default is `daemon`). `daemon` keeps the daemon alive until it's explicitly stopped while\n`session` keeps it alive until the end of the build session. This currently only affects the Scala compiler, see\nhttps://github.com/gradle/gradle/pull/21034 for a PR that attempts to do the same for the Java compiler.\n* `scalaOptimizerMode`: configures the optimizing behavior of the scala compiler, the value should be one of `none`, `method`, `inline-kafka` or\n`inline-scala` (the default is `inline-kafka`). `none` is the scala compiler default, which only eliminates unreachable code. `method` also\nincludes method-local optimizations. `inline-kafka` adds inlining of methods within the kafka packages. Finally, `inline-scala` also\nincludes inlining of methods within the scala library (which avoids lambda allocations for methods like `Option.exists`). `inline-scala` is\nonly safe if the Scala library version is the same at compile time and runtime. Since we cannot guarantee this for all cases (for example, users\nmay depend on the kafka jar for integration tests where they may include a scala library with a different version), we don't enable it by\ndefault. See https://www.lightbend.com/blog/scala-inliner-optimizer for more details.\n\n### Running system tests ###\n\nSee [tests/README.md](tests/README.md).\n\n### Using Trogdor for testing ###\n\nWe use Trogdor as a test framework for Apache Kafka. You can use it to run benchmarks and other workloads.\n\nSee [trogdor/README.md](trogdor/README.md).\n\n### Running in Vagrant ###\n\nSee [vagrant/README.md](vagrant/README.md).\n\n### Kafka client examples ###\n\nSee [examples/README.md](examples/README.md).\n\n### Contribution ###\n\nApache Kafka is interested in building the community; we would welcome any thoughts or [patches](https://issues.apache.org/jira/browse/KAFKA). You can reach us [on the Apache mailing lists](http://kafka.apache.org/contact.html).\n\nTo contribute follow the instructions here:\n * https://kafka.apache.org/contributing.html \n","funding_links":[],"categories":["Java","Streaming","Message Queues","Data Stream Processing","Projects","Official Resources","Data Management \u0026 Processing","Data Ingestion","Table of Contents","Software/System","其他__大数据","Recently Updated","Back-End Development","Streaming \u0026 Messaging","Big Data","大数据","队列( Queue )","⚙️ Data Engineering","Clients"],"sub_categories":["Vectors","TimeSeries Analysis","Message Broker","Streaming Data Management","Big Data","Message-Oriented Middleware","网络服务_其他","[Dec 11, 2024](/content/2024/12/11/README.md)","Data Pipeline","Tools","Java"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fkafka","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapache%2Fkafka","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapache%2Fkafka/lists"}