Class RedisRingBufferMessageStore

  • All Implemented Interfaces:
    de.otto.synapse.messagestore.MessageStore, java.lang.AutoCloseable

    @Beta
    public class RedisRingBufferMessageStore
    extends java.lang.Object
    implements de.otto.synapse.messagestore.MessageStore
    Redis-based implementation of a WritableMessageStore.

    The store can be configured like a ring-buffer to only store the latest N messages.

    • Constructor Summary

      Constructors 
      Constructor Description
      RedisRingBufferMessageStore​(java.lang.String name, int batchSize, int ringBufferSize, org.springframework.data.redis.core.RedisTemplate<java.lang.String,​java.lang.String> stringRedisTemplate)  
      RedisRingBufferMessageStore​(java.lang.String name, int batchSize, int ringBufferSize, org.springframework.data.redis.core.RedisTemplate<java.lang.String,​java.lang.String> stringRedisTemplate, de.otto.synapse.translator.Encoder<java.lang.String> messageEncoder, de.otto.synapse.translator.Decoder<java.lang.String> messageDecoder)  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      void add​(de.otto.synapse.messagestore.MessageStoreEntry entry)  
      void clear()  
      void close()  
      java.util.Set<java.lang.String> getChannelNames()  
      com.google.common.collect.ImmutableSet<de.otto.synapse.messagestore.Index> getIndexes()  
      de.otto.synapse.channel.ChannelPosition getLatestChannelPosition​(java.lang.String channelName)  
      long size()  
      java.util.stream.Stream<de.otto.synapse.messagestore.MessageStoreEntry> stream()  
      java.util.stream.Stream<de.otto.synapse.messagestore.MessageStoreEntry> stream​(de.otto.synapse.messagestore.Index index, java.lang.String value)
      Deprecated.
      Unsupported operation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface de.otto.synapse.messagestore.MessageStore

        getLatestChannelPosition, isCompacting
    • Constructor Detail

      • RedisRingBufferMessageStore

        public RedisRingBufferMessageStore​(java.lang.String name,
                                           int batchSize,
                                           int ringBufferSize,
                                           org.springframework.data.redis.core.RedisTemplate<java.lang.String,​java.lang.String> stringRedisTemplate)
        Parameters:
        name - the name of the message store
        batchSize - the size of the batches used to fetch messages from Redis
        ringBufferSize - the maximum number of messages stored in the ring-buffer
        stringRedisTemplate - the RedisTemplate used to access Redis
      • RedisRingBufferMessageStore

        public RedisRingBufferMessageStore​(java.lang.String name,
                                           int batchSize,
                                           int ringBufferSize,
                                           org.springframework.data.redis.core.RedisTemplate<java.lang.String,​java.lang.String> stringRedisTemplate,
                                           de.otto.synapse.translator.Encoder<java.lang.String> messageEncoder,
                                           de.otto.synapse.translator.Decoder<java.lang.String> messageDecoder)
        Parameters:
        name - the name of the message store
        batchSize - the size of the batches used to fetch messages from Redis
        ringBufferSize - the maximum number of messages stored in the ring-buffer
        stringRedisTemplate - the RedisTemplate used to access Redis
        messageEncoder - the encoder used to encode messages into the string-representation stored in Redis
        messageDecoder - the decoder used to decode messages from the string-representation stored in Redis
    • Method Detail

      • add

        public void add​(de.otto.synapse.messagestore.MessageStoreEntry entry)
        Specified by:
        add in interface de.otto.synapse.messagestore.MessageStore
      • getChannelNames

        public java.util.Set<java.lang.String> getChannelNames()
        Specified by:
        getChannelNames in interface de.otto.synapse.messagestore.MessageStore
      • getIndexes

        public com.google.common.collect.ImmutableSet<de.otto.synapse.messagestore.Index> getIndexes()
        Specified by:
        getIndexes in interface de.otto.synapse.messagestore.MessageStore
      • getLatestChannelPosition

        public de.otto.synapse.channel.ChannelPosition getLatestChannelPosition​(java.lang.String channelName)
        Specified by:
        getLatestChannelPosition in interface de.otto.synapse.messagestore.MessageStore
      • stream

        public java.util.stream.Stream<de.otto.synapse.messagestore.MessageStoreEntry> stream()
        Specified by:
        stream in interface de.otto.synapse.messagestore.MessageStore
      • stream

        public java.util.stream.Stream<de.otto.synapse.messagestore.MessageStoreEntry> stream​(de.otto.synapse.messagestore.Index index,
                                                                                              java.lang.String value)
        Deprecated.
        Unsupported operation.
        Guaranteed to throw an exception and leave the message store unmodified.
        Specified by:
        stream in interface de.otto.synapse.messagestore.MessageStore
        Throws:
        java.lang.UnsupportedOperationException - always
      • size

        public long size()
        Specified by:
        size in interface de.otto.synapse.messagestore.MessageStore
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface de.otto.synapse.messagestore.MessageStore
      • clear

        public void clear()