public RedisMessageBus(IServiceProvider serviceProvider, ILogger <RedisMessageBus> logger
                               , RedisMessageBusOptions options
                               , ConnectionMultiplexer connectionMultiplexer
                               , RedisStorage redisStorage)
        {
            _serviceProvider = serviceProvider;
            _logger          = logger;
            _options         = options;
            _redisStorage    = redisStorage;

            backgroundProcessContext = new BackgroundProcessContext();
            _processExecuter         = new ProcessExecuter(_serviceProvider, backgroundProcessContext);
        }
Exemple #2
0
        private static IServiceCollection AddService(IServiceCollection services, RedisMessageBusOptions options)
        {
            if (options.ConnectionMultiplexer != null)
            {
                services.AddSingleton(options.ConnectionMultiplexer);
            }
            else if (!string.IsNullOrEmpty(options.ConnectionString))
            {
                var redis = ConnectionMultiplexer.Connect(options.ConnectionString);
                services.AddSingleton(redis);
            }
            else
            {
                throw new Exception("ConnectionMultiplexer或RedisConnectionString为空");
            }

            services.AddSingleton(options);
            services.AddSingleton <RedisStorage>();
            return(services);
        }
Exemple #3
0
 public static string GetCrontabSetName(RedisMessageBusOptions options)
 {
     return($"{options.TopicPrefix}CrontabSet");
 }
Exemple #4
0
 public static string GetCrontabHashId(RedisMessageBusOptions options, string jobId)
 {
     return($"{options.TopicPrefix}crontabdata:{jobId}");
 }
Exemple #5
0
 public static string GetCrontabChannel(RedisMessageBusOptions options)
 {
     return($"{options.TopicPrefix}CrontabJobChannel");
 }
Exemple #6
0
 public static string GetErrorChannel(RedisMessageBusOptions options)
 {
     return($"{options.TopicPrefix}ErrorJobChannel");
 }
Exemple #7
0
 public static string GetDelayChannel(RedisMessageBusOptions options)
 {
     return($"{options.TopicPrefix}DelayJobChannel");
 }
Exemple #8
0
 public static string GetDelaySortedSetName(RedisMessageBusOptions options)
 {
     return($"{options.TopicPrefix}delay:jobid");
 }
 public RedisMessageBus_Subscriber(ILogger <RedisMessageBus_Subscriber> logger, RedisMessageBusOptions options, ConnectionMultiplexer connectionMultiplexer)
 {
     _logger  = logger;
     _options = options;
     _connectionMultiplexer = connectionMultiplexer;
     _subscriber            = _connectionMultiplexer.GetSubscriber();
 }
Exemple #10
0
 public static IServiceCollection AddRedisMessageBus(this IServiceCollection services, RedisMessageBusOptions options)
 {
     AddService(services, options);
     services.AddSingleton <IRedisMessageBus, RedisMessageBus>();
     return(services);
 }