{"id":19405707,"url":"https://github.com/jmnarloch/rxjava-spring-boot-starter","last_synced_at":"2025-04-10T00:18:46.008Z","repository":{"id":53819905,"uuid":"50104316","full_name":"jmnarloch/rxjava-spring-boot-starter","owner":"jmnarloch","description":"RxJava Spring MVC integration","archived":false,"fork":false,"pushed_at":"2021-03-12T04:26:16.000Z","size":130,"stargazers_count":181,"open_issues_count":3,"forks_count":46,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-10T00:18:40.981Z","etag":null,"topics":["java","reactive","rxjava","rxjava-spring-mvc","spring","spring-boot"],"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/jmnarloch.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":"2016-01-21T11:54:34.000Z","updated_at":"2025-03-11T00:32:26.000Z","dependencies_parsed_at":"2022-08-22T01:21:03.858Z","dependency_job_id":null,"html_url":"https://github.com/jmnarloch/rxjava-spring-boot-starter","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmnarloch%2Frxjava-spring-boot-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmnarloch%2Frxjava-spring-boot-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmnarloch%2Frxjava-spring-boot-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jmnarloch%2Frxjava-spring-boot-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jmnarloch","download_url":"https://codeload.github.com/jmnarloch/rxjava-spring-boot-starter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131341,"owners_count":21052821,"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":["java","reactive","rxjava","rxjava-spring-mvc","spring","spring-boot"],"created_at":"2024-11-10T11:39:13.779Z","updated_at":"2025-04-10T00:18:45.985Z","avatar_url":"https://github.com/jmnarloch.png","language":"Java","readme":"# Spring MVC RxJava handlers\n\n\u003e A Spring Boot starter for RxJava integration\n\n[![Build Status](https://travis-ci.org/jmnarloch/rxjava-spring-boot-starter.svg?branch=master)](https://travis-ci.org/jmnarloch/rxjava-spring-boot-starter)\n[![Coverage Status](https://coveralls.io/repos/jmnarloch/rxjava-spring-boot-starter/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/jmnarloch/rxjava-spring-boot-starter?branch=master)\n\n## Setup\n\nAdd the Spring Boot starter to your project:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003eio.jmnarloch\u003c/groupId\u003e\n  \u003cartifactId\u003erxjava-spring-boot-starter\u003c/artifactId\u003e\n  \u003cversion\u003e2.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nNote:\nIf you need RxJava 1.4.x support use version 1.0.0. For RxJava2 use 2.x. \n\n## Usage\n\n### Basic\n\nRegisters Spring's MVC return value handlers for `rx.Observable` and `rx.Single` types. You don't need to any longer use\nblocking operations or assign the values to DeferredResult or ListenableFuture instead you can declare that your REST\nendpoint returns Observable.\n\nExample:\n\n```\n@RestController\npublic static class InvoiceResource {\n\n    @RequestMapping(method = RequestMethod.GET, value = \"/invoices\", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)\n    public Observable\u003cInvoice\u003e getInvoices() {\n\n        return Observable.just(\n                new Invoice(\"Acme\", new Date()),\n                new Invoice(\"Oceanic\", new Date())\n        );\n    }\n}\n```\n\nThe `Observable` will wrap any produced results into a list and make it process through Spring's message converters.\nIn case if you need to return exactly one result you can use `rx.Single` instead. You can think of `rx.Single`\nas counterpart of Spring's `DeferredResult` or `ListenableFuture`. Also with `rx.Single`, and unlike with `rx.Observable`\nit is possible to return `ResponseEntity` in order to have the control of the HTTP headers or the status code of the\nresponse.\n\nNote: The `HandlerReturnValueHandler` for Observable uses 'toList' operator to aggregate the results, which\nis not workable with really long infinitive running Observables, from which is not possible to unsubscribe.\n\nIn some scenarios when you want to have more control over the async processing you can use either `ObservableDeferredResult`\nor `SingleDeferredResult`, those are the specialized implementation of `DeferredResult` allowing for instance of setting\nthe processing timeout per response.\n\n### Server side events\n\nSpring 4.2 introduced `ResponseBodyEmitter` for long-lived HTTP connections and streaming the response data. One of\navailable specialized implementations is `ObservableSseEmitter` that allows to send server side event produced\nfrom `rx.Observable`.\n\nExample:\n\n```\n@RestController\npublic static class Events {\n\n    @RequestMapping(method = RequestMethod.GET, value = \"/messages\")\n    public ObservableSseEmitter\u003cString\u003e messages() {\n        return new ObservableSseEmitter\u003cString\u003e(\n            Observable.just(\n                \"message 1\", \"message 2\", \"message 3\"\n            )\n        );\n    }\n}\n```\n\nThis will output:\n\n```\ndata: message 1\n\ndata: message 2\n\ndata: message 3\n```\n\nThe SSE can be conveniently consumed by a JavaScript client for instance.\n\n## Properties\n\nThe only supported property is `rxjava.mvc.enabled` which allows to disable this extension.\n\n```\nrxjava.mvc.enabled=true # true by default\n```\n\n## License\n\nApache 2.0\n","funding_links":[],"categories":["spring-boot-starter"],"sub_categories":["非官方"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmnarloch%2Frxjava-spring-boot-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjmnarloch%2Frxjava-spring-boot-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjmnarloch%2Frxjava-spring-boot-starter/lists"}