My best practices for operating Redis stream with redis template in Spring Boot 2.x
- Verify FullName(stream + group + consumer_name) not blank and duplicate, when register Listener
-
com.itplh.best.practices.stream.MyStreamListener
add the following extensions:- getStream()
- getGroup()
- getConsumerName()
- getFullName()
- getFullGroup()
- Abstract class
com.itplh.best.practices.stream.AbstractAutoRetryStreamListener
- Automatically enable the failed retry mechanism, when the stream is single consume group
- default maximum retry count: 10
- customize the override of the 'maxRetries' method
- Support successful callback
onSuccess
- Support failure callback (reaching the max retries)
onFailure
- Support finally callback
onFinally
- Automatically enable the failed retry mechanism, when the stream is single consume group
- Java 1.8
- Redis 5.0.10
- Spring Boot 2.3.4.RELEASE
- spring-boot-starter-data-redis 2.3.4.RELEASE
- Jackson 2.11.2
- Lombok 1.18.12
- Run
com.itplh.best.practices.Application
- push data to stream
curl --location --request GET 'http://localhost:8080/redis/stream/push-data?stream=stream_test1'