Class RedisStreamTransport
- All Implemented Interfaces:
Closeable, AutoCloseable
Redis Streams: cn1.messaging.url=redis://... (or rediss://). Works with
Redis 6.2 or newer, Valkey and KeyDB.
A destination is a stream and a group a consumer group, created on first
use: each group gets every message, and the consumers of one group share
them. A message is an entry with its payload, key and headers as fields;
acknowledging it is XACK. A consumer that dies leaves its messages
pending, and another consumer of the group claims them once they have been
idle for cn1.messaging.lease milliseconds (60000) -- counting that as
another delivery, so a message that crashes its consumer is dead-lettered
like one that throws.
A failed message stays pending, and its next delivery waits in a sorted set per destination and group until it is due; only the group whose listener failed sees it again.
Streams are capped at about cn1.messaging.redis.max-length entries
(100000, trimmed with MAXLEN ~), so a destination nobody reads cannot
grow without bound.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOpens the transport forredis://andrediss://URLs; the generated wiring registers it when the configuration names one.Nested classes/interfaces inherited from class PollingTransport
PollingTransport.Delivery -
Field Summary
Fields inherited from class PollingTransport
retry -
Constructor Summary
ConstructorsConstructorDescriptionRedisStreamTransport(RedisKeyValueStore redis, RetryPolicy retry, long leaseMillis, long maxLength) A transport overredis, which it closes. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidack(String destination, String group, PollingTransport.Delivery delivery) Acknowledges a handled delivery.voidclose()Stops every subscription and closes the connection.getName()The scheme this transport was opened for:memory,db,redis,amqp,kafka.booleanWhether the broker answers, for the health endpoint.protected List<PollingTransport.Delivery> Up tomaxmessages ofdestinationforgroup, waiting up towaitMillisfor the first; an empty list when none came.protected voidredeliver(String destination, String group, PollingTransport.Delivery delivery, int attempt, long notBefore) Hasdeliverydelivered again, asattempt, no sooner thannotBefore.voidSendsmessage.Methods inherited from class PollingTransport
deadLetter, identified, notYet, stopSubscriptions, subscribeMethods inherited from class MessageTransport
isTransactional
-
Constructor Details
-
RedisStreamTransport
public RedisStreamTransport(RedisKeyValueStore redis, RetryPolicy retry, long leaseMillis, long maxLength) A transport overredis, which it closes.
-
-
Method Details
-
getName
Description copied from class:MessageTransportThe scheme this transport was opened for:memory,db,redis,amqp,kafka.- Specified by:
getNamein classMessageTransport
-
send
Description copied from class:MessageTransportSendsmessage. With a database transport inside a transaction the message is written in that transaction and is seen only if it commits.- Specified by:
sendin classMessageTransport- Throws:
IOException
-
poll
protected List<PollingTransport.Delivery> poll(String destination, String group, int max, long waitMillis) throws IOException Description copied from class:PollingTransportUp tomaxmessages ofdestinationforgroup, waiting up towaitMillisfor the first; an empty list when none came.- Specified by:
pollin classPollingTransport- Throws:
IOException
-
ack
protected void ack(String destination, String group, PollingTransport.Delivery delivery) throws IOException Description copied from class:PollingTransportAcknowledges a handled delivery.- Specified by:
ackin classPollingTransport- Throws:
IOException
-
redeliver
protected void redeliver(String destination, String group, PollingTransport.Delivery delivery, int attempt, long notBefore) throws IOException Description copied from class:PollingTransportHasdeliverydelivered again, asattempt, no sooner thannotBefore. The default sends a copy carrying the attempt and the time in its headers and acknowledges the original; a consumer that polls the copy early puts it back withPollingTransport.notYet(Message, long).- Overrides:
redeliverin classPollingTransport- Throws:
IOException
-
isHealthy
public boolean isHealthy()Description copied from class:MessageTransportWhether the broker answers, for the health endpoint. Never throws.- Overrides:
isHealthyin classMessageTransport
-
close
public void close()Description copied from class:MessageTransportStops every subscription and closes the connection. Never throws.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein classMessageTransport
-