Spring Reactive Sample

June 4, 2026 ยท View on GitHub

Note

A huge thanks to @rajadilipkolli for his efforts in updating this repository to the newest Spring Boot v4.

This is a sandbox project for demonstrating Reactive Streams support in the Spring framework and the broader Spring ecosystem.

I've also maintained a series of repositories related to Reactive Streams and the latest Spring 5:

The source codes have been updated to Spring 7 / Spring Boot v4.

Documentation

Read online: https://hantsy.github.io/spring-reactive-sample/

Sample Codes

The following table lists all sample codes available in this repository.

Spring Samples

NameDescription
vanillaBasic spring-webflux features with a main class to start the application
vanilla-jettySame as vanilla, but uses Jetty as the runtime
vanilla-tomcatSame as vanilla, but uses Tomcat as the runtime
vanilla-undertowSame as vanilla, but uses Undertow as the runtime
java8Java 8 CompletableFuture and @Async example
java9Same as vanilla, with Java 9 Flow API support (see SPR-16052)
rxjava3Same as vanilla, but uses RxJava 3 instead of Reactor (since Spring 5.3.0)
smallrye-mutinySame as vanilla, but uses SmallRye Mutiny instead of Reactor (since Spring 5.3.10)
rxjava3Same as vanilla, but use Rxjava3 instead of Reactor, since Spring 5.3.0
smallrye-mutinySame as vanilla, but use SmallRye Mutiny instead of Reactor, since Spring 5.3.10
warReplaces the manual bootstrap with Spring ApplicationInitializer, can be packaged as a war file for external servlet containers
routesUses RouterFunction instead of @Controller
register-beanProgrammatic bean registration in ApplicationContext at bootstrap
data-elasticsearchSpring Data ElasticSearch Reactive example
data-neo4jSpring Data Neo4j reactive example
data-mongoSpring Data Mongo Reactive example
data-mongo-pageableSpring Data Mongo Reactive example with pagination support
data-mongo-transactionSpring Data Mongo Reactive example with Transaction support
data-redisSpring Data Redis Reactive example
data-redis-messageSpring Data Redis Reactive example with ReactiveRedisMessageListenerContainer
data-cassandraSpring Data Cassandra Reactive example
data-couchbaseSpring Data Couchbase Reactive example
securityAdds Spring Security Reactive support to vanilla
security-formSame as security, with login form example
security-user-propertiesSame as security, but stores users in users.properties
security-methodReplaces URI-based configuration with method-level constraints
security-data-mongoBased on data-mongo and security, replaces hard-coded users with Mongo-driven store
multipartMultipart request handling and file uploading
multipart-data-mongoMultipart and file uploading, data stored in Mongo via Spring Data Mongo Reactive GridFsTemplate
mvc-thymeleafTraditional web application using Thymeleaf as template engine
mvc-mustacheTraditional web application using Mustache as template engine
mvc-freemarkerTraditional web application using Freemarker as template engine
sseServer Send Event example
websocketWebSocket example
web-filterWebFilter example
groovyWritten in Groovy
groovy-dslGroovy DSL bean definition example
clientWebClient example for calling backend reactive APIs
client-jettyWebClient with Jetty Reactive HttpClient
client-jdk11-httpclientWebClient with JDK 11 HttpClient
client-apache-httpclient5WebClient with Apache HttpClient 5
cacheCache Async/Reactive support with in-memory ConcurrentHashMap
cache-caffeineCache Async/Reactive support with Caffeine
cache-redisCache Async/Reactive support with Redis
eventApplication Event Reactive example
kotlinWritten in Kotlin
kotlin-coWritten in Kotlin Coroutines
kotlin-routesKotlin functional approach to declare beans and bootstrap programmatically
kotlin-dslKotlin DSL bean definition example
scheduleSpring Schedule Reactive example
sessionSpring Session example
session-headerSpring Session WebSessionIdResolver example
session-data-redisSpring Data Redis based ReactiveSessionRepository example
session-data-mongoSpring Data Mongo based ReactiveSessionRepository example
exception-handlerException Handler example
integrationSpring Integration example
integration-dslSpring Integration Java 8 DSL example
restdocsSpring RestDocs example

Spring Boot Samples

NameDescription
boot-startSpring Boot example with 3 Maven profiles to switch between Jetty, Tomcat, and Undertow
boot-start-routesSimple RouterFunction example
boot-mvc-thymeleafSame as mvc-thymeleaf, based on Spring Boot
boot-mvc-mustacheSame as mvc-mustache, based on Spring Boot
boot-mvc-freemarkerSame as mvc-freemarker, based on Spring Boot
boot-groovyWritten in Groovy
boot-kotlinWritten in Kotlin
boot-kotlin-coWritten in Kotlin Coroutines
boot-kotlin-dslKotlin-specific BeanDefinitionDSL and RouterFunctionDsl example
boot-kotlin-co-dslKotlin-specific BeanDefinitionDSL and CoRouterFunctionDsl example
boot-redisExample using ReactiveRedisConnection and RouterFunction
boot-data-redisSpring Data Redis example
boot-data-neo4jSpring Data Neo4j example (Spring Boot 2.4)
boot-neo4jSpring Data Neo4j using ReactiveNeo4jOperations (Spring Boot 2.4)
boot-neo4j-cypherSpring Data Neo4j using ReactiveNeo4jClient (Spring Boot 2.4)
boot-data-cassandraSpring Data Cassandra example
boot-data-couchbaseSpring Data Couchbase example
boot-data-elasticsearchSpring Data ElasticSearch example
boot-data-mongoSpring Data Mongo example (Repository, Auditing, testcontainers)
boot-data-mongo-querydslSpring Data Mongo example with QueryDSL support
boot-data-mongo-gridfsSpring Data Mongo example with GridFS support
boot-data-mongo-tailableSpring Data Mongo tailable document example
boot-exception-handlerGlobal Exception Handler example
boot-cassandraSpring Boot Cassandra example
boot-couchbaseSpring Boot Couchbase example
boot-elasticsearchSpring Boot ElasticSearch example
boot-mongoSpring Boot Mongo example
boot-data-mongo-templateSpring Data Mongo template example
boot-data-neo4j-cypherSpring Data Neo4j using Cypher example
boot-data-neo4j-templateSpring Data Neo4j template example
boot-data-redis-templateSpring Data Redis template example

Legacy Codes

Some example codes are becoming deprecated over time; for example, the SDN Rx project, maintained by the Neo4j team, has been discontinued. It is highly recommended to migrate to the official Spring Data Neo4j. Reactor Kafka and Reactor Rabbit are discontinued, Netty 5 support(the development is inactive) was finally removed in the Spring framework.

Spring Data R2dbc 1.2 introduced many breaking changes, so I created another Spring R2dbc Sample repository to introduce the new features.

Spring removed support of RxJava/RxJava2, and other projects, such as Spring Data, will remove RxJava/RxJava2 support soon.

namedescription
data-r2dbcSpring Data R2dbc Example. (Deprecated, go to hantsy/spring-r2dbc-sample to update yourself)
data-r2dbc-postgresqlSpring Data R2dbc Example, but use PostgreSQL instead(Deprecated)
boot-r2dbcSpring Data R2dbc example using DatabaseClient(Deprecated)
boot-data-r2dbcSpring Data R2dbc example(Deprecated)
boot-data-r2dbc-auditing@EnableR2dbcAuditing example(Deprecated)
boot-data-r2dbc-postgresqlSame as boot-data-r2dbc, but use PostgresSQL instead(Deprecated)
boot-data-r2dbc-mysqlSame as boot-data-r2dbc, but use MySQL instead(Deprecated)
boot-data-r2dbc-mssqlSame as boot-data-r2dbc, but use MS SQL instead(Deprecated)
boot-neo4j-rxSDN Rx Example but use ReactiveNeo4jClient(Deprecated)
boot-neo4j-rx-cypherSDN Rx Example using Cypher queries(Deprecated)
boot-data-neo4j-rxSDN Rx Example(Deprecated)
rxjavaSame as vanilla, but use Rxjava instead of Reactor
rxjava-jdbcAccessing database with rxjava-jdbc. NOTE: rxjava-jdbc is a wrapper of blocking Jdbc APIs
rxjava2Same as vanilla, but use Rxjava2 instead of Reactor
rxjava2-jdbcAccessing database with rxjava2-jdbc. NOTE: rxjava2-jdbc is a wrapper of blocking Jdbc APIs
websocket-reactor-netty2WebSocket example with Reactor Netty 2
vanilla-reactor-netty2Same as vanilla, but uses Reactor Netty 2.x as the runtime
client-reactor-netty2WebClient with Reactor Netty 2.x HttpClient
boot-pulsarSpring for Pulsar Reactive example

References

Special Thanks

Special thanks to JetBrains for supporting an open-source license.