/webflux-rsocket-cqrs-app

Play with Spring Webflux, RSocket API and reactive streams...

Primary LanguageJavaMIT LicenseMIT

webflux-rsocket-cqrs-app Build Status

Play with Spring Webflux, RSocket API, R2DBC and reactive streams...

Full non-blocking end-to-end reactive stack by using RSocket, WebFlux, R2DBC and reactive streams!

                  users-command
                    +-------+     TCP
         COMMAND    | WRITE |   RSocket
         HTTP ,>-~->~  SIDE ~>-~->~.                             _______
             /      | :8081 |       \  shared +-------+         '       `
   _O_ -~->~'       +-------+        `-~->-~->~ :7000 |         |  D B  |
    |                                | single | users <~-R2DBC-~> EVENT |
   / \ -<-~-.       +-------+        ,-<-~-<-~- :7000 |         |  LOG  |
             \      |  READ |       / connect.+-------+         `_______,
         HTTP `<-~-<~  SIDE <-~-~<-'          
         QUERY      | :8082 |   RSocket
         STREAM     +-------+     TCP
                   users-query

required jdk 11

# jdk11
jenv local 11.0
# build
./mvnw
# run
java -jar         ./users/target/*.jar &
java -jar   ./users-query/target/*.jar &
java -jar ./users-command/target/*.jar &
# queries
http get      :8082/find-users
curl localhost:8082/stream-users
# commands
http post :8081 name=ololo   username=ololo
http post :8081 name=trololo username=trololo
# teardown
killall -9 java

parallel subscription filtering

# subscribe with filters:
curl "localhost:8082/stream-users/?query=max&?query=fax" &
http --stream ":8082/stream-users?query=billy&?query=bob" Accept:"application/stream+json" &
# this won't be delivered to subscribers:
http :8081 name="Maksim Ko" username=maksimko >/dev/null
http :8081 name="Ololo Trololo" username=ololo.trololo >/dev/null
# this will be seen:delivered only to second subscriber:
http :8081 name="Billy Bob Thornton" username=billy.bob >/dev/null
# this will be seen:delivered to both subscriber:
http :8081 name="Billy" username=Max >/dev/null

resources