{"id":51160722,"url":"https://github.com/bewaremypower/pulsar-protobuf-native-demo","last_synced_at":"2026-06-26T13:02:06.265Z","repository":{"id":359245465,"uuid":"1242251670","full_name":"BewareMyPower/pulsar-protobuf-native-demo","owner":"BewareMyPower","description":"Example for ProtobufNative schema in Pulsar","archived":false,"fork":false,"pushed_at":"2026-05-21T01:54:41.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-21T08:22:47.634Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"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/BewareMyPower.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-18T08:59:31.000Z","updated_at":"2026-05-21T01:54:45.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/BewareMyPower/pulsar-protobuf-native-demo","commit_stats":null,"previous_names":["bewaremypower/pulsar-protobuf-native-demo"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/BewareMyPower/pulsar-protobuf-native-demo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fpulsar-protobuf-native-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fpulsar-protobuf-native-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fpulsar-protobuf-native-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fpulsar-protobuf-native-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BewareMyPower","download_url":"https://codeload.github.com/BewareMyPower/pulsar-protobuf-native-demo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BewareMyPower%2Fpulsar-protobuf-native-demo/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34817641,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-26T02:00:06.560Z","response_time":106,"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":[],"created_at":"2026-06-26T13:02:05.413Z","updated_at":"2026-06-26T13:02:06.260Z","avatar_url":"https://github.com/BewareMyPower.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nLicensed to the Apache Software Foundation (ASF) under one or more\ncontributor license agreements.  See the NOTICE file distributed with\nthis work for additional information regarding copyright ownership.\nThe ASF licenses this file to You under the Apache License, Version 2.0\n(the \"License\"); you may not use this file except in compliance with\nthe License.  You may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n--\u003e\n\n# pulsar-protobuf-native-demo\n\nThe demo to show the ProtobufNative schema support in Pulsar Python client.\n\n## Build the Java CLI tools\n\nSee [./pulsar-pb-native-java/README.md](./pulsar-pb-native-java/README.md) for instructions to build the Java CLI tools.\n\n## Build\n\nInstall Python client 3.12.0 with protobuf support:\n\n```bash\npython3 -m pip install 'pulsar_client[protobuf]==3.12.0' --force-reinstall\n```\n\n## Demo\n\n### Step 1: start a Pulsar standalone\n\n```bash\n./bin/pulsar standalone -nss -nfw\n```\n\n### Step 2: Run a Java producer to produce some messages with ProtobufNative schema\n\n```bash\ncd ./pulsar-pb-native-java\nmvn clean package -DskipTests\njava -jar target/pulsar-pb-native-java-1.0.0-SNAPSHOT.jar produce --topic test-topic\ncd ..\n```\n\nExample logs:\n\n```\nProduced messageId=20:0:-1 sequence=1 id=54cd1111-d920-4ad3-a255-bc6b702fab56 content=message-1 created_at=2026-05-18T08:55:02.054Z created_at_ms=1779094502054\nProduced messageId=20:1:-1 sequence=2 id=382e139d-ddb5-4237-b07d-928615c766e3 content=message-2 created_at=2026-05-18T08:55:02.075Z created_at_ms=1779094502075\nProduced messageId=20:2:-1 sequence=3 id=20c8738d-3d4f-4442-bb98-94f66853a8bf content=message-3 created_at=2026-05-18T08:55:02.078Z created_at_ms=1779094502078\nProduced messageId=20:3:-1 sequence=4 id=e1b142de-b868-4716-b08a-3ec79d3b468e content=message-4 created_at=2026-05-18T08:55:02.081Z created_at_ms=1779094502081\nProduced messageId=20:4:-1 sequence=5 id=e9317862-cf0a-4831-b4dc-834b8b76b9ea content=message-5 created_at=2026-05-18T08:55:02.084Z created_at_ms=1779094502084\n```\n\n### Step 3: Run a Python script to produce and consume messages of ProtobufNative schema\n\nThe Python client example `pb_demo.py` provides two approaches to specify ProtobufNative schema:\n\n1. (Default) From pre-generated class `demo_message_pb2.py` generated with the command above:\n\n    ```bash\n    protoc \\\n      --proto_path=./pulsar-pb-native-java/src/main/proto \\\n      --python_out=. \\\n      ./pulsar-pb-native-java/src/main/proto/demo_message.proto\n    ```\n\n2. Dynamically generate the class from the proto file at runtime via the `build_dynamic_class()` function in the script. You can specify the `--message-class dynamic` option to choose this approach.\n\n```bash\npython3 pb_demo.py --topic test-topic\n```\n\nOutputs:\n\n```\nConsumed message_id=(20,0,-1,-1) sequence=1 id=54cd1111-d920-4ad3-a255-bc6b702fab56 content=message-1 created_at_ms=1779094502054\nConsumed message_id=(20,1,-1,-1) sequence=2 id=382e139d-ddb5-4237-b07d-928615c766e3 content=message-2 created_at_ms=1779094502075\nConsumed message_id=(20,2,-1,-1) sequence=3 id=20c8738d-3d4f-4442-bb98-94f66853a8bf content=message-3 created_at_ms=1779094502078\nConsumed message_id=(20,3,-1,-1) sequence=4 id=e1b142de-b868-4716-b08a-3ec79d3b468e content=message-4 created_at_ms=1779094502081\nConsumed message_id=(20,4,-1,-1) sequence=5 id=e9317862-cf0a-4831-b4dc-834b8b76b9ea content=message-5 created_at_ms=1779094502084\nConsumed message_id=(20,5,-1,-1) sequence=-1 id=100 content=Python! created_at_ms=1234567890\n```\n\nYou can see the first 5 messages match the ones produced by the Java producer, and the last message is produced by the Python script itself.\n\n### Step 4: Consume these messages via a Java consumer\n\n```bash\ncd ./pulsar-pb-native-Java\njava -jar target/pulsar-pb-native-java-1.0.0-SNAPSHOT.jar consume --topic test-topic --subscription sub --max-messages 6\n```\n\nOutputs:\n\n```\nConsumed messageId=20:0:-1 sequence=1 id=54cd1111-d920-4ad3-a255-bc6b702fab56 content=message-1 created_at=2026-05-18T08:55:02.054Z created_at_ms=1779094502054\nConsumed messageId=20:1:-1 sequence=2 id=382e139d-ddb5-4237-b07d-928615c766e3 content=message-2 created_at=2026-05-18T08:55:02.075Z created_at_ms=1779094502075\nConsumed messageId=20:2:-1 sequence=3 id=20c8738d-3d4f-4442-bb98-94f66853a8bf content=message-3 created_at=2026-05-18T08:55:02.078Z created_at_ms=1779094502078\nConsumed messageId=20:3:-1 sequence=4 id=e1b142de-b868-4716-b08a-3ec79d3b468e content=message-4 created_at=2026-05-18T08:55:02.081Z created_at_ms=1779094502081\nConsumed messageId=20:4:-1 sequence=5 id=e9317862-cf0a-4831-b4dc-834b8b76b9ea content=message-5 created_at=2026-05-18T08:55:02.084Z created_at_ms=1779094502084\nConsumed messageId=20:5:-1 sequence=-1 id=100 content=Python! created_at=1970-01-15T06:56:07.89Z created_at_ms=1234567890\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbewaremypower%2Fpulsar-protobuf-native-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbewaremypower%2Fpulsar-protobuf-native-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbewaremypower%2Fpulsar-protobuf-native-demo/lists"}