Coder Social home page Coder Social logo

oriflame / redismessaging.reliabledelivery Goto Github PK

View Code? Open in Web Editor NEW
6.0 5.0 0.0 147 KB

This library is written in .NET standard and provides reliability to delivering messages via Redis. By design Redis pub/sub message delivery is not reliable so it can happen that some messages can be lost due to network issues or they can be delivered more than once in case of Redis replication failure.

License: GNU Lesser General Public License v3.0

C# 100.00%
redis publish subscribe reliable guaranteed delivery failover pubsub messaging

redismessaging.reliabledelivery's Introduction

Oriflame.RedisMessaging.ReliableDelivery

This library is written in .NET standard and provides reliability to delivering messages via Redis. By design Redis pub/sub message delivery is not reliable so it can happen that some messages can get lost due to network issues or they can be delivered more than once in case of Redis replication failure.

This library adds a lightweight infrastructure to handle such error scenarios.

Download Nuget package

Nuget Nuget

How to Use It

// initialization
var multiplexer = ConnectionMultiplexer.Connect("connection options");

// subscribe to a reliable channel
var channelIntegrityCheck = multiplexer.GetSubscriber()
    .Reliably()
    .Subscribe(
        channel: "channel-name",
        onExpectedMessage: (channel, message) => Trace.TraceInformation($"Message with ID={message.Id} was received as expected. Message content='{message.Content}'"),
        onMissedMessage:,
        onDuplicatedMessage:,
        onMissingMessages:);

// publish to a reliable channel
multiplexer.GetSubscriber()
    .Reliably()
    .Publish(
        channel: "channel-name",
        message: "message-content",
        messageExpiration: TimeSpan.FromMinutes(10));

// channel integrity check - optional
// useful when delivering messages is not as frequent. In such a case
// we can ensure manually that reliable subscriber is still able to receive messages.
// Example:
// if last processed message was earlier than 1sec ago
// i.e. we did not receive messages within the last second
if (channelIntegrityCheck.LastActivityAt < DateTime.UtcNow.AddSeconds(-1))
{
    // force reliable channel to get not processed messages
    // from Redis server if there are some
    channelIntegrityCheck.CheckForMissedMessages();
}

How It Works

TODO

Limitations

  • Subscribing to channel patterns is not supported

Development

Build status

Build status Nuget (with prereleases)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.