Add redis: Boot 4.1 + Spring Data Redis 4.1, the JDK-serialisation default vs Jackson 3 serializers, @RedisHash TTL and keyspace events, @RedisListener, and Redis as the Spring cache
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B38FGKKam5SCGgwgduVAh3
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
# Pub/Sub: what is delivered, to whom, and what is lost
|
||||
|
||||
|
||||
--- The container Boot created ---
|
||||
beans of type RedisMessageListenerContainer: [redisMessageListenerContainer]
|
||||
running=true listening=true
|
||||
|
||||
--- Publishing to a channel nobody listens to ---
|
||||
template.convertAndSend("quiet", "hello?") = 0 receivers
|
||||
$ redis-cli -p 6390 --no-raw PUBSUB NUMSUB quiet
|
||||
1) "quiet"
|
||||
2) (integer) 0
|
||||
|
||||
--- Publishing to news, which has an @RedisListener ---
|
||||
$ redis-cli -p 6390 --no-raw PUBSUB NUMSUB news
|
||||
1) "news"
|
||||
2) (integer) 1
|
||||
template.convertAndSend("news", "first") = 1 receiver
|
||||
@RedisListener got 'first'
|
||||
|
||||
--- A second listener that subscribes late ---
|
||||
container.addMessageListener(late, new ChannelTopic("news"))
|
||||
$ redis-cli -p 6390 --no-raw PUBSUB NUMSUB news
|
||||
1) "news"
|
||||
2) (integer) 1
|
||||
template.convertAndSend("news", "second") = 1 receiver
|
||||
@RedisListener got 'first'
|
||||
@RedisListener got 'second'
|
||||
late listener got 'second' on news
|
||||
|
||||
--- A pattern subscription (topic = "alerts.*") ---
|
||||
$ redis-cli -p 6390 --no-raw PUBSUB NUMPAT
|
||||
(integer) 1
|
||||
$ redis-cli -p 6390 --no-raw PUBSUB NUMSUB alerts.disk
|
||||
1) "alerts.disk"
|
||||
2) (integer) 0
|
||||
template.convertAndSend("alerts.disk", "90% full") = 1 receiver
|
||||
@RedisListener got '90% full' on alerts.disk
|
||||
Reference in New Issue
Block a user