{"id":20834966,"url":"https://github.com/hstreamdb/hstreamdb-java","last_synced_at":"2025-10-20T09:29:34.452Z","repository":{"id":36970678,"uuid":"383707539","full_name":"hstreamdb/hstreamdb-java","owner":"hstreamdb","description":"Java Client for HStreamDB","archived":false,"fork":false,"pushed_at":"2024-02-18T07:14:02.000Z","size":6032,"stargazers_count":6,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-08T02:39:32.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/hstreamdb.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}},"created_at":"2021-07-07T07:12:04.000Z","updated_at":"2023-08-22T11:24:58.000Z","dependencies_parsed_at":"2025-05-08T02:46:08.999Z","dependency_job_id":null,"html_url":"https://github.com/hstreamdb/hstreamdb-java","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/hstreamdb/hstreamdb-java","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hstreamdb%2Fhstreamdb-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hstreamdb%2Fhstreamdb-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hstreamdb%2Fhstreamdb-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hstreamdb%2Fhstreamdb-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hstreamdb","download_url":"https://codeload.github.com/hstreamdb/hstreamdb-java/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hstreamdb%2Fhstreamdb-java/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259546410,"owners_count":22874560,"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":[],"created_at":"2024-11-18T00:22:12.771Z","updated_at":"2025-10-20T09:29:29.407Z","avatar_url":"https://github.com/hstreamdb.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hstreamdb-java\n\n![Build Status](https://github.com/hstreamdb/hstreamdb-java/actions/workflows/main.yml/badge.svg)\n[![Maven Central](https://img.shields.io/maven-central/v/io.hstream/hstreamdb-java)](https://search.maven.org/artifact/io.hstream/hstreamdb-java)\n[![javadoc](https://javadoc.io/badge2/io.hstream/hstreamdb-java/0.17.0/javadoc.svg)](https://javadoc.io/doc/io.hstream/hstreamdb-java/0.17.0)\n[![Snapshot Artifacts](https://img.shields.io/nexus/s/https/s01.oss.sonatype.org/io.hstream/hstreamdb-java.svg)](https://s01.oss.sonatype.org/content/repositories/snapshots/io/hstream/hstreamdb-java/0.17.0-SNAPSHOT/)\n[![javadoc](https://javadoc.io/badge2/io.hstream/hstreamdb-java/0.17.0-SNAPSHOT/javadoc.svg)](https://hstreamdb.github.io/hstreamdb-java/javadoc/)\n\nThis is the official Java client library for [HStreamDB](https://hstream.io/).\n\n**Please use the latest released version.**\n\n**The latest release is v0.17.0, which requires HStreamDB v0.17.0 .**\n\n## Content\n- [Installation](#installation)\n    - [Maven](#maven)\n    - [Gradle](#gradle)\n- [Example Usage](#example-usage)\n    - [Connect to HStreamDB](#connect-to-hstreamdb)\n    - [Work with Streams](#work-with-streams)\n    - [Write Data to a Stream](#write-data-to-a-stream)\n    - [Consume Data from a Stream](#consume-data-from-a-subscription)\n    - [Read Data from a Stream Shard](#read-data-from-a-stream-shard)\n\n\n## Installation\n\nThe library artifact is published in Maven central,\navailable at [hstreamdb-java](https://search.maven.org/artifact/io.hstream/hstreamdb-java).\n\n### Maven\n\nFor Maven Users, the library can be included easily like this:\n\n```xml\n\n\u003cdependencies\u003e\n  \u003cdependency\u003e\n    \u003cgroupId\u003eio.hstream\u003c/groupId\u003e\n    \u003cartifactId\u003ehstreamdb-java\u003c/artifactId\u003e\n    \u003cversion\u003e0.17.0\u003c/version\u003e\n  \u003c/dependency\u003e\n\u003c/dependencies\u003e\n\n```\n\n### Gradle\n\nFor Gradle Users, the library can be included easily like this:\n\n```groovy\n\nimplementation 'io.hstream:hstreamdb-java:0.17.0'\n\n```\n\n## Example Usage\n\nHere we will show you some simple examples to use hstreamdb-client,\nyou can find the complete examples in [hstreamdb-java-examples](https://github.com/hstreamdb/hstreamdb-java-examples),\nfor more detail on introduction and usage, please check the [guides](https://docs.hstream.io/write/write.html).\n\n### Connect to HStreamDB\n\n```java\n\nimport io.hstream.*;\n\npublic class ConnectExample {\n    public static void main(String[] args) throws Exception {\n        final String serviceUrl = \"localhost:6570\";\n        HStreamClient client = HStreamClient.builder().serviceUrl(serviceUrl).build();\n        System.out.println(\"Connected\");\n        client.close();\n    }\n}\n\n```\n\n### Work with Streams\n\n```java\n\n// get a list of streams\nfor(Stream stream: client.listStreams()) {\n  System.out.println(stream.getStreamName());\n}\n\n\n// create a new stream\nclient.createStream(\"test_stream\");\n\n// create a new stream with 5 replicas\nclient.createStream(\"test_stream\", 5);\n\n\n// delete a stream\nclient.deleteStream(\"test_stream\");\n\n```\n\n### Write Data to a Stream\n\n```java\n\nProducer producer = client.newProducer().stream(\"test_stream\").build();\n\n// write raw records\nRandom random = new Random();\nbyte[] rawRecord = new byte[100];\nrandom.nextBytes(rawRecord);\nRecord recordR = Record.newBuilder().rawRecord(rawRecord).build();\nCompletableFuture\u003cString\u003e future = producer.write(recordR);\n\n// write hRecords\nHRecord hRecord = HRecord.newBuilder()\n        .put(\"key1\", 10)\n        .put(\"key2\", \"hello\")\n        .put(\"key3\", true)\n        .build();\nRecord recordH = Record.newBuilder().hRecord(hRecord).build();\nCompletableFuture\u003cString\u003e future = producer.write(recordH);\n\n// buffered writes\nBatchSetting batchSetting =\n    BatchSetting.newBuilder()\n        .recordCountLimit(100)\n        .bytesLimit(4096)\n        .ageLimit(100)\n        .build();\n\nFlowControlSetting flowControlSetting =\n    FlowControlSetting.newBuilder()\n        .bytesLimit(40960)\n        .build();\n\nBufferedProducer batchedProducer =\n    client.newBufferedProducer().stream(\"test_stream\")\n            .batchSetting(batchSetting)\n            .flowControlSetting(flowControlSetting)\n            .build();\n\nfor(int i = 0; i \u003c 1000; ++i) {\n    random.nextBytes(rawRecord);\n    Record recordB = Record.newBuilder().rawRecord(rawRecord).build();\n    batchedProducer.write(recordB);\n}\n// flush and close batchedProducer\nbatchedProducer.close();\n\n```\n\n**Please do not write both binary data and hrecord in one stream.**\n\n\n### Consume Data from a Subscription\n\n```java\n// first, create a subscription for the stream\nSubscription subscription = \n    Subscription\n        .newBuilder()\n        .subscription(\"my_subscription\")\n        .stream(\"my_stream\")\n        .ackTimeoutSeconds(600)\n        .build();\nclient.createSubscription(subscription);\n\n// second, create a consumer attach to the subscription\nConsumer consumer =\n    client\n        .newConsumer()\n        .subscription(\"my_subscription\")\n        .rawRecordReceiver(\n            ((receivedRawRecord, responder) -\u003e {\n                System.out.println(receivedRawRecord.getRecordId());\n                responder.ack();\n            }))\n        .build();\n\n// third, start the consumer\nconsumer.startAsync().awaitRunning();\nSystem.out.println(\"the consumer is started\");\n\n```\n\n### Read Data from a Stream Shard\n\n```java\n\nReader reader =\n    client\n        .newReader()\n        .readerId(\"my_readerId\")\n        .streamName(\"my_stream\")\n        .shardId(\"my_shardId\")\n        .build();\n\n\nList\u003cRecord\u003e records = reader.read(10).join();\n\nreader.close();\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhstreamdb%2Fhstreamdb-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhstreamdb%2Fhstreamdb-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhstreamdb%2Fhstreamdb-java/lists"}