{"id":21625393,"url":"https://github.com/eigr/astreu4j","last_synced_at":"2025-07-17T11:31:34.510Z","repository":{"id":54181110,"uuid":"337585230","full_name":"eigr/astreu4j","owner":"eigr","description":"Astreu Java client","archived":false,"fork":false,"pushed_at":"2021-03-04T19:44:38.000Z","size":530,"stargazers_count":3,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-05-02T01:15:31.566Z","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/eigr.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}},"created_at":"2021-02-10T01:31:13.000Z","updated_at":"2024-05-02T01:15:31.567Z","dependencies_parsed_at":"2022-08-13T08:31:16.170Z","dependency_job_id":null,"html_url":"https://github.com/eigr/astreu4j","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eigr%2Fastreu4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eigr%2Fastreu4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eigr%2Fastreu4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eigr%2Fastreu4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eigr","download_url":"https://codeload.github.com/eigr/astreu4j/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226256099,"owners_count":17595862,"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-25T01:09:04.512Z","updated_at":"2024-11-25T01:09:05.116Z","avatar_url":"https://github.com/eigr.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Astreu4j\nAstreu Java client\n\n[![Maven Build](https://github.com/eigr/astreu4j/actions/workflows/maven.yml/badge.svg)](https://github.com/eigr/astreu4j/actions/workflows/maven.yml) [![Maven Release](https://github.com/eigr/astreu4j/actions/workflows/release.yml/badge.svg)](https://github.com/eigr/astreu4j/actions/workflows/release.yml)\n\n## Usage\n\nCreate Subscriber\n\n```java\npackage io.eigr.astreu.examples;\n\nimport io.eigr.astreu.Astreu;\nimport io.eigr.astreu.protocol.Exchange;\nimport io.eigr.astreu.subscriber.AcknowledgeContext;\nimport io.eigr.astreu.subscriber.MessageWithContext;\nimport org.reactivestreams.Publisher;\nimport reactor.core.publisher.Flux;\n\nclass SubscriberExample {\n\n    public static void main(final String[] args) {\n        final Publisher\u003cMessageWithContext\u003e publisher =\n                Astreu.at(\"127.0.0.1\", 9980)\n                        .asSub(\"test\", \"unique-subscription\")\n\n                        // You can use some filter options during receive messages\n                        //.filter(msg -\u003e true)\n                        //.receiveOnly(MessageType.EXCHANGE)\n\n                        //.bindWithThrottle(1, Duration.ofSeconds(1), 2);\n                        .bind(); //This create a org.reactivestreams.Publisher\n\n        // Then use with any Reactive Streams framework (build-in with Project Reactor or Akka)\n        Flux.from(publisher).subscribe(messageWithContext -\u003e {\n            final AcknowledgeContext context = messageWithContext.getContext();\n\n            //Messages can be of some types: [Exchange, Info, Failure]\n            context.logger().debug(\"Message type is -\u003e {}\", messageWithContext.getType());\n            // I am assuming it is an Exchange, but you should check this out before doing this here\n            final Exchange message = messageWithContext.getMessage();\n\n            context.logger().info(\"Incoming Message {}\", message);\n\n            /* Request / Response pattern is supported\n            context.reply(\n                    Exchange.newBuilder()\n                            .setUuid(UUID.randomUUID().toString())\n                            .setMessage(\n                                    Any.newBuilder()\n                                    .setTypeUrl(\"your.custom.package.type/YourTypeHere\")\n                                    .setValue(ByteString.copyFrom(\"Hello I got your message\".getBytes()))\n                                    .build())\n                            .build());\n\n            */\n\n            // Or simply confirm or reject the message\n            context.accept(); // Send acknowledge or reject message with context.reject()\n        });\n    }\n}\n\n```\n\nCreate Publisher\n\n```java\npackage io.eigr.astreu.examples;\n\nimport com.google.protobuf.Any;\nimport com.google.protobuf.ByteString;\nimport io.eigr.astreu.Astreu;\nimport io.eigr.astreu.Producer;\nimport io.eigr.astreu.publisher.ReplyMessage;\nimport org.reactivestreams.Publisher;\nimport reactor.core.publisher.Flux;\n\nimport java.util.UUID;\n\nclass ProducerExample {\n\n    public static void main(final String[] args) {\n\n        final Producer producer =\n                Astreu.at(\"127.0.0.1\", 9980)\n                .asPub(\"test\", UUID.randomUUID().toString().toLowerCase());\n\n        final Publisher\u003cReplyMessage\u003e publisher = producer.bind(); //This create a org.reactivestreams.Publisher\n\n        // Then use with any Reactive Streams framework (build-in with Project Reactor or Akka)\n        Flux.from(publisher).subscribe(replyMessage -\u003e {\n            //Messages can be of some types: [Ack, Exchange, Info, Failure]\n            replyMessage.logger().info(\"Reply Message -\u003e {}\", replyMessage);\n        });\n\n        for (int i = 0; i \u003c 500000; i++) {\n            producer.publish(\n                    String.valueOf(i), //id of a message or use producer.publish(any) For automatic creation of UUID-based ids\n                    Any.newBuilder()\n                            .setTypeUrl(\"io.astreu.custom/Text\")\n                            .setValue(ByteString.copyFrom(String.format(\"Hello World Astreu %s\", i).getBytes()))\n                            .build()\n            );\n        }\n    }\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feigr%2Fastreu4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feigr%2Fastreu4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feigr%2Fastreu4j/lists"}