{"id":16410212,"url":"https://github.com/perkss/c-kafka-examples","last_synced_at":"2025-08-03T03:11:04.953Z","repository":{"id":55491326,"uuid":"317342320","full_name":"perkss/c-kafka-examples","owner":"perkss","description":"Examples using Kafka with C and C++","archived":false,"fork":false,"pushed_at":"2020-12-05T14:39:59.000Z","size":20,"stargazers_count":6,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-04T04:27:19.364Z","etag":null,"topics":["avro","avro-kafka","c","cmake","cmakelists","cplusplus","googletest","gtest","kafka","rdkafka"],"latest_commit_sha":null,"homepage":"","language":"C","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/perkss.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}},"created_at":"2020-11-30T20:48:59.000Z","updated_at":"2023-09-14T16:06:36.000Z","dependencies_parsed_at":"2022-08-15T01:40:22.064Z","dependency_job_id":null,"html_url":"https://github.com/perkss/c-kafka-examples","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/perkss/c-kafka-examples","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perkss%2Fc-kafka-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perkss%2Fc-kafka-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perkss%2Fc-kafka-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perkss%2Fc-kafka-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/perkss","download_url":"https://codeload.github.com/perkss/c-kafka-examples/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/perkss%2Fc-kafka-examples/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268488682,"owners_count":24258314,"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-03T02:00:12.545Z","response_time":2577,"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":["avro","avro-kafka","c","cmake","cmakelists","cplusplus","googletest","gtest","kafka","rdkafka"],"created_at":"2024-10-11T06:23:31.303Z","updated_at":"2025-08-03T03:11:04.906Z","avatar_url":"https://github.com/perkss.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# C Kafka Examples\n\nMixing the old with the new. Kafka examples with C using [RDKafka](https://github.com/edenhill/librdkafka).\n\n### MAC OS Installation\n1) Install the dependent library for Kafka:\n```shell script\nbrew install librdkafka\n```\nThis will install into the `/usr/local/include` and `/usr/local/lib` which we will include in CMake to find the header files.\n\nCheck the headers are installed\n```shell script\npkg-config --cflags rdkafka\n```\nCheck the libs are intalled\n```shell script\npkg-config --libs rdkafka\n```\n\n### Option 1 CMAKE Build\n```shell script\nmkdir build \u0026\u0026 cd build   \ncmake ..\nmake\n```\n\n```shell script\n ./MainProject/src/MainProject localhost:9091 my-lowercase-consumer lowercase-topic\n```\n\n### Option 2 Command Build\n\n[Lib File Mac Ref](https://stackoverflow.com/questions/3532589/how-to-build-a-dylib-from-several-o-in-mac-os-x-using-gcc)\n[Header File Library](https://stackoverflow.com/questions/58334781/mac-dylib-linking-cannot-find-header)\n\n```shell script\n# Create object files for the Library files\ngcc -Wall -g -c src/consumer.c -o consumer.o -I include/\ngcc -Wall -g -c src/UppercaseTopology.c -o UppercaseTopology.o -I include/\n# Todo UNIX?\nar ruv mylib.a consumer.o UppercaseTopology.o\n# Create Mac Shared Lib\ngcc -dynamiclib -undefined suppress -flat_namespace consumer.o UppercaseTopology.o -o libmyProject.dylib\n\n# Need to be in the directory where the .dylib file is \ngcc -Wall -std=c11 -L/Users/Stuart/Documents/Programming/C_Programming/c-kafka-examples/LibProject/ -lmyProject -lrdkafka MainProject/src/main.c -o myconsumer -I LibProject/include\n\n```\nNote we found the `rdkafka` library and linked as its on the usual path we can search for it using \n\n```shell script\npkg-config --libs rdkafka\n```\n\n3) Start up Kafka.\n\n```shell script\ndocker exec kafka-1 kafka-topics --create --zookeeper zookeeper-1:22181 --replication-factor 1 --partitions 1 --topic lowercase-topic\n```\n\n```shell script\ndocker exec kafka-1 kafka-topics --create --zookeeper zookeeper-1:22181 --replication-factor 1 --partitions 1 --topic uppercase-topic\n```\n\n```shell script\ndocker exec kafka-1 kafka-topics --zookeeper zookeeper-1:22181 --list\n```\n\n\n\n```shell script\n./myconsumer localhost:9091 my-lowercase-consumer lowercase-topic\n```\n\n```shell script\ndocker exec -it kafka-1 kafka-console-producer --broker-list kafka-1:29091 --topic lowercase-topic --property \"parse.key=true\" --property \"key.separator=:\"\n```\n\n```shell script\ndocker exec kafka-1 kafka-console-consumer --bootstrap-server kafka-1:29091 --topic uppercase-topic --property print.key=true --property key.separator=\"-\" --from-beginning\n```\n\n\n## Useful Docker\nStop and remove all running containers.\n```shell script\ndocker stop $(docker ps -a -q)\ndocker rm $(docker ps -a -q)\n```\n\n## TODO\n* Avro example\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperkss%2Fc-kafka-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperkss%2Fc-kafka-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperkss%2Fc-kafka-examples/lists"}