Giter VIP home page Giter VIP logo

powerfly.abp.eventbus.redis's Introduction

Distributed Event Bus Redis Integration

Similar to Volo.Abp.EventBus.Kafka, but it's use redis stream.

Thanks to BenLocal/Rebus.Redis.Transport, I used some of his code in my project.

This document explains how to configure the redis as the distributed event bus provider. See the distributed event bus document to learn how to use the distributed event bus system

Installation

Use the ABP CLI to add Powerfly.Abp.EventBus.Redis NuGet package to your project:

  • Install the ABP CLI if you haven't installed before.
  • Open a command line (terminal) in the directory of the .csproj file you want to add the Powerfly.Abp.EventBus.Redis package.
  • Run abp add-package Powerfly.Abp.EventBus.Redis command.

If you want to do it manually, install the Powerfly.Abp.EventBus.Redis NuGet package to your project and add [DependsOn(typeof(PowerflyAbpEventBusRedisModule))] to the ABP module class inside your project.

Configuration

You can configure using the standard configuration system, like using the appsettings.json file, or using the options classes.

appsettings.json file configuration

This is the simplest way to configure the Redis settings. It is also very strong since you can use any other configuration source (like environment variables) that is supported by the AspNet Core.

Example: The minimal configuration to connect to a local redis server with default configurations

{
  "Redis": {
    "Connections": {
      "Default": {
        "Configuration": "localhost:6379"
      }
    },
    "EventBus": {
      "GroupName": "MyGroupName",
      "TopicName": "MyTopicName"
    }
  }
}
  • MyGroupName is the name of this application, which is used as the GroupName on the Redis.
  • MyTopicName is the topic name.

See the Redis document to understand these options better.

Connections

If you need to connect to another server than the localhost, you need to configure the connection properties.

Example: Specify the host name (as an IP address)

{
  "Redis": {
    "Connections": {
      "Default": {
        "Configuration": "123.123.123.123:6379"
      }
    },
    "EventBus": {
      "GroupName": "MyGroupName",
      "TopicName": "MyTopicName"
    }
  }
}

Defining multiple connections is allowed. In this case, you can specify the connection that is used for the event bus.

Example: Declare two connections and use one of them for the event bus

{
  "Redis": {
    "Connections": {
      "Default": {
        "Configuration": "123.123.123.123:6379"
      },
      "SecondConnection": {
        "Configuration": "321.321.321.321:6379"
      }
    },
    "EventBus": {
      "GroupName": "MyGroupName",
      "TopicName": "MyTopicName",
      "ConnectionName": "SecondConnection"
    }
  }
}

This allows you to use multiple Redis cluster in your application, but select one of them for the event bus.

The Options Classes

PowerflyAbpRedisOptions and PowerflyAbpRedisEventBusOptions classes can be used to configure the connection strings and event bus options for the Redis.

You can configure this options inside the ConfigureServices of your module.

Example: Configure the connection

Configure<PowerflyAbpRedisOptions>(options =>
{
    options.Connections.Default.Configuration = "123.123.123.123:6379,defaultDatabase=1,password=qwed8s7w5a9t63";
});

Example: Configure the consumer config

Configure<PowerflyAbpRedisOptions>(options =>
{
    options.ConfigureConsumer = config =>
    {
        config.GroupName = "MyGroupName";
        config.ProcessingTimeout = TimeSpan.FromSeconds(60);
    };
});

Example: Configure the producer config

Configure<PowerflyAbpRedisOptions>(options =>
{
    options.ConfigureProducer = config =>
    {
        config.MaxLength = 1000;
    };
});

Using these options classes can be combined with the appsettings.json way. Configuring an option property in the code overrides the value in the configuration file.

powerfly.abp.eventbus.redis's People

Contributors

ifirstshow avatar

Watchers

 avatar

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.