{"id":19405643,"url":"https://github.com/johnament/reactive-cdi-events","last_synced_at":"2025-06-20T18:05:29.031Z","repository":{"id":68090591,"uuid":"107064787","full_name":"johnament/reactive-cdi-events","owner":"johnament","description":"A simple prototype of using Project Reactor with CDI Events","archived":false,"fork":false,"pushed_at":"2017-10-16T01:55:24.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-25T00:47:16.459Z","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/johnament.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}},"created_at":"2017-10-16T01:42:05.000Z","updated_at":"2017-10-16T22:43:53.000Z","dependencies_parsed_at":"2023-09-12T09:00:30.644Z","dependency_job_id":null,"html_url":"https://github.com/johnament/reactive-cdi-events","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/johnament/reactive-cdi-events","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnament%2Freactive-cdi-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnament%2Freactive-cdi-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnament%2Freactive-cdi-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnament%2Freactive-cdi-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnament","download_url":"https://codeload.github.com/johnament/reactive-cdi-events/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnament%2Freactive-cdi-events/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260993716,"owners_count":23094268,"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-10T11:38:55.947Z","updated_at":"2025-06-20T18:05:24.018Z","avatar_url":"https://github.com/johnament.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Project Reactor Meets CDI Events\n\nSometimes a good weekend in the mountains gets the creative juices flowing.\n\nSo what happens when you mix [Project Reactor](https://projectreactor.io/) with the CDI event programming model?  You get to `Flux` your way through events!\n\nThe built in event model in CDI only supports `void` methods or async invocations.  You can convert the resulting `CompletionStage` to a `Mono` using an approach like this\n\n```java\nCompletionStage\u003cString\u003e stringCompletionStage = seContainer.getBeanManager().getEvent().fireAsync(\"\");\nMono\u003cString\u003e mono = Mono.fromCompletionStage(stringCompletionStage);\n```\n\nBut that only allows you to ever look at one result.  I wanted to beable to get all of the results.  There is quite a bit of code required to make it work, but I can fully support an observer method pattern with injected dependencies dynamically.\n\nTo get started, inject a `ReactorEvent\u003cS,R\u003e` where `S` is the sender type, and `R` is the return type.\n\n```java\n    @Inject\n    private ReactorEvent\u003cString, String\u003e event;\n\n    public void fluxTheCapacitor() {\n        event.fire(\"my incoming msg\")\n                .publishOn(Schedulers.single())\n                .log(\"com.foo.bar\", Level.SEVERE)\n                .subscribe(System.out::println);\n    }\n```\n\nThis sends an event with payload `my incoming msg` and will print out any results it receives.  You can register an observer\n\n```java\n    public Flux\u003cString\u003e handle(@ObservesReactor String msg) {\n        return Flux.just(\"bob\");\n    }\n    public String another(@ObservesReactor String msg, FooBarBean fooBarBean) {\n        return \"ralph \"+msg+fooBarBean.toString();\n    }\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnament%2Freactive-cdi-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnament%2Freactive-cdi-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnament%2Freactive-cdi-events/lists"}