marcoCasamento / Hangfire.Redis.StackExchange

HangFire Redis storage based on original (and now unsupported) Hangfire.Redis but using lovely StackExchange.Redis client
Other
452 stars 108 forks source link

Multiple Dashboards #62

Closed aeb-dev closed 8 months ago

aeb-dev commented 6 years ago

http://docs.hangfire.io/en/latest/configuration/using-dashboard.html#multiple-dashboards as mentioned here I would like to use multiple dashboards. However, it seems like one redis option overrides the other. I can visualize both UI but jobs listed always belong to the second prefix. Is it not supported or something else is going on? Any ideas?

This is how I register dashboards

public static void UseHangfireDashboardWithSettings(this IApplicationBuilder app)
{
    var redis = app.ApplicationServices.GetRequiredService<IRedisManager>().GetConfigurationOptions();
    var connectionString = redis.ToString();

    app.UseHangfireDashboard(
        pathMatch: "/jobs1",
        options: new DashboardOptions
        {
            AppPath = "/",
            Authorization = new[] { new HangfireDashboardAuthorizationFilter() },
        },
        storage: new RedisStorage(connectionString, new RedisStorageOptions
        {
            Prefix = "hangfire1:",
            InvisibilityTimeout = TimeSpan.FromMinutes(30),
            FetchTimeout = TimeSpan.FromMinutes(3),
            Db = redis.DefaultDatabase.GetValueOrDefault(),
            SucceededListSize = 499,
            DeletedListSize = 499
        })
    );

    app.UseHangfireDashboard(
        pathMatch: "/jobs2",
        options: new DashboardOptions
        {
            AppPath = "/",
            Authorization = new[] { new HangfireDashboardAuthorizationFilter() },
        },
        storage: new RedisStorage(connectionString, new RedisStorageOptions
        {
            Prefix = "hangfire2:",
            InvisibilityTimeout = TimeSpan.FromMinutes(30),
            FetchTimeout = TimeSpan.FromMinutes(3),
            Db = redis.DefaultDatabase.GetValueOrDefault(),
            SucceededListSize = 499,
            DeletedListSize = 499
        })
    );
}

and this is how I register RedisStorage before registering dashboard

public static class ServiceCollectionExtensions
{
     public static void AddHangfireForRedis(this IServiceCollection services)
     {
         services.AddHangfire(configuration => configuration.UseRedisStorage());
     }
}
marcoCasamento commented 6 years ago

Uh, I was not aware of such possibility, serving multiple dashboard from one server. I'll definitely take a look into. There's also a quite big refactor in a PR (that it's working) and possibly could solve the problem.

I'll have a look into that soon!

Il 21 ago 2017 10:27 AM, "Ahmet Enes Bayraktar" notifications@github.com ha scritto:

http://docs.hangfire.io/en/latest/configuration/using- dashboard.html#multiple-dashboards as mentioned here I would like to use multiple dashboards. However, it seems like one redis option overrides the other. I can visualize both UI but jobs listed always belong to the second prefix. Is it not supported or something else is going on? Any ideas?

This is how I register dashboards

`public static void UseHangfireDashboardWithSettings(this IApplicationBuilder app) { var redis = app.ApplicationServices.GetRequiredService(). GetConfigurationOptions(); var connectionString = redis.ToString();

app.UseHangfireDashboard(
        pathMatch: "/jobs1",
        options: new DashboardOptions
        {
                AppPath = "/",
                Authorization = new[] { new HangfireDashboardAuthorizationFilter() },
        },
        storage: new RedisStorage(connectionString, new RedisStorageOptions
        {
                Prefix = "/hangfire1:",
                InvisibilityTimeout = TimeSpan.FromMinutes(30),//Default: 30 dakika
                FetchTimeout = TimeSpan.FromMinutes(3),//Default: 3 dakika
                Db = redis.DefaultDatabase.GetValueOrDefault(),
                SucceededListSize = 499,//Default: 499
                DeletedListSize = 499 //Default: 499
        })
);

app.UseHangfireDashboard(
        pathMatch: "/jobs2:",
        options: new DashboardOptions
        {
                AppPath = "/",
                Authorization = new[] { new HangfireDashboardAuthorizationFilter() },
        },
        storage: new RedisStorage(connectionString, new RedisStorageOptions
        {
                Prefix = "hangfire2:",
                InvisibilityTimeout = TimeSpan.FromMinutes(30),//Default: 30 dakika
                FetchTimeout = TimeSpan.FromMinutes(3),//Default: 3 dakika
                Db = redis.DefaultDatabase.GetValueOrDefault(),
                SucceededListSize = 499,//Default: 499
                DeletedListSize = 499 //Default: 499
        })
);

}`

and this is how I register RedisStorage before registering dashboard

public static class ServiceCollectionExtensions { public static void AddHangfireForRedis(this IServiceCollection services) { services.AddHangfire(configuration => configuration.UseRedisStorage()); } }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/marcoCasamento/Hangfire.Redis.StackExchange/issues/62, or mute the thread https://github.com/notifications/unsubscribe-auth/AANtY-dZY5k4waqNkiSdaaluorQ-9tBMks5saT9rgaJpZM4O9B8j .

aeb-dev commented 6 years ago

Any updates so far?

pieceofsummer commented 6 years ago

@MrMuMu the current code does support that already. It is not published to NuGet yet, but you can build from sources and use it.

Toumash commented 8 months ago

Should be closed