Spring Boot Redis Streams CI

This repository contains event driven redis app uses redis streams

Run redis in docker

docker run --rm --name redis -itp6379:6379 redis:6.2.6-alpine

HTTPie

mvn spring-boot:start

http --stream :8080 &
http :8080 body=Hello
http :8080 body=World

mvn spring-boot:stop

Manual

Create a redis stream called my_stream

docker exec -it redis redis-cli
127.0.0.1:6379> XADD my_stream * value "Hello, World!"
# output: identity, which is message id:
"1637443677304-0"

Check what identity we have in redis

127.0.0.1:6379> KEYS *
# output:
"my_stream"

Check type of key my_stream

127.0.0.1:6379> TYPE my_stream
# output:
stream

Consume that stream

127.0.0.1:6379> XREAD STREAMS my_stream 0
# output:
1) 1) "my_stream"
   2) 1) 1) "1637443677304-0"
         2) 1) "value"
            2) "Hello, World!"

Continue read stream from a last message I get

127.0.0.1:6379> XREAD STREAMS my_stream 1637443677304-0
# output:
(nil)

Wait by blocking for 5 seconds for a next value from a stream

127.0.0.1:6379> XREAD BLOCK 5000 STREAMS my_stream 1637443677304-0
# output:
(nil)
(5.09s)

Cleanup

docker stop redis

rtfm

GitHub

View Github