Class RedisQueue<CLIENT extends redis.clients.jedis.commands.JedisCommands>
java.lang.Object
cn.sliew.carp.framework.queue.kekio.AbstractLifecycle
cn.sliew.carp.framework.queue.kekio.AbstractQueue
cn.sliew.carp.framework.queue.kekio.redis.AbstractRedisQueue<CLIENT>
cn.sliew.carp.framework.queue.kekio.redis.RedisQueue<CLIENT>
- All Implemented Interfaces:
MonitorableQueue,Queue,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle
- Direct Known Subclasses:
JedisClusterQueue,JedisQueue
public abstract class RedisQueue<CLIENT extends redis.clients.jedis.commands.JedisCommands>
extends AbstractRedisQueue<CLIENT>
-
Nested Class Summary
Nested classes/interfaces inherited from class cn.sliew.carp.framework.queue.kekio.redis.AbstractRedisQueue
AbstractRedisQueue.FingerprintNested classes/interfaces inherited from interface cn.sliew.carp.framework.queue.kekio.metrics.MonitorableQueue
MonitorableQueue.QueueStateNested classes/interfaces inherited from interface cn.sliew.carp.framework.queue.kekio.Queue
Queue.DeadMessageCallback, Queue.QueueCallback -
Field Summary
Fields inherited from class cn.sliew.carp.framework.queue.kekio.redis.AbstractRedisQueue
lockTtlSeconds, mapper, READ_MESSAGE_SRC, READ_MESSAGE_WITH_LOCK_SRCFields inherited from class cn.sliew.carp.framework.queue.kekio.AbstractQueue
ackTimeout, canPollMany, deadMessageHandlers, publisherFields inherited from interface cn.sliew.carp.framework.queue.kekio.Queue
MAX_RETRIESFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
ConstructorsConstructorDescriptionRedisQueue(com.fasterxml.jackson.databind.ObjectMapper mapper, String name, QueueExecutor queueExecutor, Collection<MessageHandler> handlers, List<Queue.DeadMessageCallback> deadMessageHandlers, EventPublisher publisher, io.micrometer.core.instrument.MeterRegistry meterRegistry, Boolean fillExecutorEachCycle, Duration requeueDelay, Duration requeueMaxJitter, Boolean canPollMany, TemporalAmount ackTimeout, Integer lockTtlSeconds) -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsMessage(Predicate<Message> predicate) protected Stringprotected Stringprotected Stringprotected Stringprotected Stringprotected Stringvoidpoll(int maxMessages, Queue.QueueCallback callback) Polls the queue for ready messages, processing up-to [maxMessages].voidpoll(Queue.QueueCallback callback) Polls the queue for ready messages.voidpush(Message message, TemporalAmount delay) Push [message] for delivery after [delay].protected voidqueueMessage(Message message, TemporalAmount delay) protected voidreadMessage(String fingerprint, String json, Consumer<Message> block) protected voidreadMessageWithoutLock(String fingerprint, Consumer<Message> block) protected voidremoveMessage(String fingerprint) protected voidrequeueMessage(String fingerprint) voidretry()Check for any un-acknowledged messages that are overdue and move them back onto the queue.protected voidMethods inherited from class cn.sliew.carp.framework.queue.kekio.redis.AbstractRedisQueue
anyZismember, cacheScript, canPollMany, fingerprint, firstFingerprint, getAckTimeout, getDeadMessageHandlers, getPublisher, handleDeadMessage, hashV1, hashV2, hgetInt, hgetInt, multi, score, score, withJedis, withJedis, zismemberMethods inherited from class cn.sliew.carp.framework.queue.kekio.AbstractQueue
doStart, doStop, getNameMethods inherited from class cn.sliew.carp.framework.queue.kekio.AbstractLifecycle
isRunning, start, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.context.Lifecycle
isRunning, start, stopMethods inherited from interface cn.sliew.carp.framework.queue.kekio.metrics.MonitorableQueue
fireMethods inherited from interface org.springframework.context.SmartLifecycle
getPhase, isAutoStartup, stop
-
Constructor Details
-
RedisQueue
public RedisQueue(com.fasterxml.jackson.databind.ObjectMapper mapper, String name, QueueExecutor queueExecutor, Collection<MessageHandler> handlers, List<Queue.DeadMessageCallback> deadMessageHandlers, EventPublisher publisher, io.micrometer.core.instrument.MeterRegistry meterRegistry, Boolean fillExecutorEachCycle, Duration requeueDelay, Duration requeueMaxJitter, Boolean canPollMany, TemporalAmount ackTimeout, Integer lockTtlSeconds)
-
-
Method Details
-
getQueueKey
- Specified by:
getQueueKeyin classAbstractRedisQueue<CLIENT extends redis.clients.jedis.commands.JedisCommands>
-
getUnackedKey
- Specified by:
getUnackedKeyin classAbstractRedisQueue<CLIENT extends redis.clients.jedis.commands.JedisCommands>
-
getMessagesKey
- Specified by:
getMessagesKeyin classAbstractRedisQueue<CLIENT extends redis.clients.jedis.commands.JedisCommands>
-
getLocksKey
- Specified by:
getLocksKeyin classAbstractRedisQueue<CLIENT extends redis.clients.jedis.commands.JedisCommands>
-
getAttemptsKey
- Specified by:
getAttemptsKeyin classAbstractRedisQueue<CLIENT extends redis.clients.jedis.commands.JedisCommands>
-
getReadMessageWithLockScriptSha
- Specified by:
getReadMessageWithLockScriptShain classAbstractRedisQueue<CLIENT extends redis.clients.jedis.commands.JedisCommands>
-
setReadMessageWithLockScriptSha
- Specified by:
setReadMessageWithLockScriptShain classAbstractRedisQueue<CLIENT extends redis.clients.jedis.commands.JedisCommands>
-
poll
Description copied from interface:QueuePolls the queue for ready messages.Implementations may invoke [callback] any number of times. Some implementations may deliver a maximum of one message per call, others may deliver all ready messages.
If no messages exist on the queue or all messages have a remaining delay [callback] is not invoked.
Messages *must* be acknowledged by calling the function passed to [callback] or they will be retried after [ackTimeout]. Acknowledging via a nested callback allows the message to be processed asynchronously.
- Parameters:
callback- invoked with the next message from the queue if there is one and an _acknowledge_ function to call once processing is complete.
-
poll
Description copied from interface:QueuePolls the queue for ready messages, processing up-to [maxMessages]. -
push
Description copied from interface:QueuePush [message] for delivery after [delay]. -
retry
@Scheduled(fixedDelayString="${queue.retry.frequency.ms:10000}") public void retry()Description copied from interface:QueueCheck for any un-acknowledged messages that are overdue and move them back onto the queue.This method is not intended to be called by clients directly but typically scheduled in some way.
-
readState
-
containsMessage
-
queueMessage
-
requeueMessage
-
removeMessage
-
readMessageWithoutLock
-
readMessageWithLock
-
readMessage
-