All Projects → jmnarloch → Rxjava Spring Boot Starter

jmnarloch / Rxjava Spring Boot Starter

Licence: apache-2.0
RxJava Spring MVC integration

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Rxjava Spring Boot Starter

Reactive Ms Example
An educational project to learn reactive programming with Spring 5
Stars: ✭ 157 (-12.78%)
Mutual labels:  reactive, spring-boot, spring
Spring Boot Webflux Jjwt
Example Spring Boot and WebFlux (Reactive Web) with Spring Security and JWT for token Authentication and Authorization
Stars: ✭ 71 (-60.56%)
Mutual labels:  reactive, spring-boot, spring
Java Spring Cloud
Distributed tracing for Spring Boot, Cloud and other Spring projects
Stars: ✭ 326 (+81.11%)
Mutual labels:  rxjava, spring-boot, spring
Hex Arch Kotlin Spring Boot
Reference JVM multi module project for a reactive micro service and lambda using a hexagonal architecture, DDD, Kotlin, Spring Boot, Quarkus, Lambda, Gradle.
Stars: ✭ 83 (-53.89%)
Mutual labels:  reactive, spring-boot, spring
Spring Reactive Sample
Spring 5 Reactive playground
Stars: ✭ 867 (+381.67%)
Mutual labels:  rxjava, spring-boot, spring
Webfluxtemplate
Spring Webflux template application with working Spring Security, Web-sockets, Rest, Web MVC, and Authentication with JWT.
Stars: ✭ 107 (-40.56%)
Mutual labels:  reactive, spring-boot, spring
Bird Java
bird-java是以Spring Boot为基础的开发增强组件包。
Stars: ✭ 154 (-14.44%)
Mutual labels:  spring-boot, spring
Spring Boot Blog
spring boot & mybatis 示例
Stars: ✭ 154 (-14.44%)
Mutual labels:  spring-boot, spring
Spring Samples
A series of examples used to demonstrate certain features of Spring.
Stars: ✭ 154 (-14.44%)
Mutual labels:  spring-boot, spring
Study
全栈工程师学习笔记;Spring登录、shiro登录、CAS单点登录和Spring boot oauth2单点登录;Spring data cache 缓存,支持Redis和EHcahce; web安全,常见web安全漏洞以及解决思路;常规组件,比如redis、mq等;quartz定时任务,支持持久化数据库,动态维护启动暂停关闭;docker基本用法,常用image镜像使用,Docker-MySQL、docker-Postgres、Docker-nginx、Docker-nexus、Docker-Redis、Docker-RabbitMQ、Docker-zookeeper、Docker-es、Docker-zipkin、Docker-ELK等;mybatis实践、spring实践、spring boot实践等常用集成;基于redis的分布式锁;基于shared-jdbc的分库分表,支持原生jdbc和Spring Boot Mybatis
Stars: ✭ 159 (-11.67%)
Mutual labels:  spring-boot, spring
Spring Thrift Starter
Set of cool annotations that helps you building Thrift applications with Spring Boot
Stars: ✭ 151 (-16.11%)
Mutual labels:  spring-boot, spring
Java Specialagent
Automatic instrumentation for 3rd-party libraries in Java applications with OpenTracing.
Stars: ✭ 156 (-13.33%)
Mutual labels:  spring-boot, spring
Biking2
This is the source code of http://biking.michael-simons.eu
Stars: ✭ 162 (-10%)
Mutual labels:  spring-boot, spring
Spring Boot Inside
spring boot技术细节的相关demo
Stars: ✭ 154 (-14.44%)
Mutual labels:  spring-boot, spring
Cas Client Autoconfig Support
Annotation-based configuration support for Apereo CAS Java clients
Stars: ✭ 153 (-15%)
Mutual labels:  spring-boot, spring
Charon Spring Boot Starter
Reverse proxy implementation in form of a Spring Boot starter.
Stars: ✭ 155 (-13.89%)
Mutual labels:  spring-boot, spring
Angular Spring Reactive Sample
RESTful API demos with Spring 5 WebFlux, Spring Boot 2, Spring Data Mongo, Spring Security, Spring Session and Angular 11
Stars: ✭ 153 (-15%)
Mutual labels:  reactive, spring-boot
Spring And Spring Boot
Lab solutions for Spring and Spring Boot course
Stars: ✭ 163 (-9.44%)
Mutual labels:  spring-boot, spring
Speedment
Speedment is a Stream ORM Java Toolkit and Runtime
Stars: ✭ 1,978 (+998.89%)
Mutual labels:  spring-boot, spring
Rxjava2 Extras
Utilities for use with RxJava 2
Stars: ✭ 167 (-7.22%)
Mutual labels:  rxjava, reactive

Spring MVC RxJava handlers

A Spring Boot starter for RxJava integration

Build Status Coverage Status

Setup

Add the Spring Boot starter to your project:

<dependency>
  <groupId>io.jmnarloch</groupId>
  <artifactId>rxjava-spring-boot-starter</artifactId>
  <version>2.0.0</version>
</dependency>

Note: If you need RxJava 1.4.x support use version 1.0.0. For RxJava2 use 2.x.

Usage

Basic

Registers Spring's MVC return value handlers for rx.Observable and rx.Single types. You don't need to any longer use blocking operations or assign the values to DeferredResult or ListenableFuture instead you can declare that your REST endpoint returns Observable.

Example:

@RestController
public static class InvoiceResource {

    @RequestMapping(method = RequestMethod.GET, value = "/invoices", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public Observable<Invoice> getInvoices() {

        return Observable.just(
                new Invoice("Acme", new Date()),
                new Invoice("Oceanic", new Date())
        );
    }
}

The Observable will wrap any produced results into a list and make it process through Spring's message converters. In case if you need to return exactly one result you can use rx.Single instead. You can think of rx.Single as counterpart of Spring's DeferredResult or ListenableFuture. Also with rx.Single, and unlike with rx.Observable it is possible to return ResponseEntity in order to have the control of the HTTP headers or the status code of the response.

Note: The HandlerReturnValueHandler for Observable uses 'toList' operator to aggregate the results, which is not workable with really long infinitive running Observables, from which is not possible to unsubscribe.

In some scenarios when you want to have more control over the async processing you can use either ObservableDeferredResult or SingleDeferredResult, those are the specialized implementation of DeferredResult allowing for instance of setting the processing timeout per response.

Server side events

Spring 4.2 introduced ResponseBodyEmitter for long-lived HTTP connections and streaming the response data. One of available specialized implementations is ObservableSseEmitter that allows to send server side event produced from rx.Observable.

Example:

@RestController
public static class Events {

    @RequestMapping(method = RequestMethod.GET, value = "/messages")
    public ObservableSseEmitter<String> messages() {
        return new ObservableSseEmitter<String>(
            Observable.just(
                "message 1", "message 2", "message 3"
            )
        );
    }
}

This will output:

data: message 1

data: message 2

data: message 3

The SSE can be conveniently consumed by a JavaScript client for instance.

Properties

The only supported property is rxjava.mvc.enabled which allows to disable this extension.

rxjava.mvc.enabled=true # true by default

License

Apache 2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].