I am using
Dotnet Framework 4.7.2
Hangfire.Core 1.6.25
Hangfire.SqlServer 1.6.25
Hangfire.SqlServer.RabbitMQ 1.6.0
hangfire.aspnet 0.2.0
I encountered a bug in the dashboard when using hangfire with rabbitmq. I clicked on the “Enqueued” link, all my queues in rabbitmq went missing and the job in enqueues are also missing. showing only 20/2 enqueued.
This is the code for my server.
var options = new BackgroundJobServerOptions
{
ServerName = strServerPrefix + String.Format("{0}.{1}", Environment.MachineName, Guid.NewGuid().ToString()),
Queues = new string [] { "default", "queue" }
};
GlobalConfiguration.Configuration
.UseDashboardMetric(SqlServerStorage.ActiveConnections)
.UseDashboardMetric(DashboardMetrics.EnqueuedAndQueueCount)
.UseDashboardMetric(DashboardMetrics.ProcessingCount)
.UseDashboardMetric(DashboardMetrics.FailedCount)
.UseDashboardMetric(DashboardMetrics.SucceededCount)
.UseNLogLogProvider();
JobStorage.Current = new SqlServerStorage("db_connection", new SqlServerStorageOptions
{
PrepareSchemaIfNecessary = true,
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(60),
}).UseRabbitMq(conf =>
{
conf.HostName = strRabbitMQ_HostName;
conf.Port = intRabbitMQ_Port;
conf.Username = strRabbitMQ_Username;
conf.Password = strRabbitMQ_Password;
conf.VirtualHost = strRabbitMQ_VirtualHost;
}, new string [] { "default", "queue" });
app.UseHangfireServer(options);
// Make `Back to site` link working for subfolder applications
//var options = new DashboardOptions { AppPath = VirtualPathUtility.ToAbsolute("~") };
app.UseHangfireDashboard("", new DashboardOptions()
{
AppPath = VirtualPathUtility.ToAbsolute("~"),
Authorization = new[] { new CustomAuthorizeFilter() }
});
This is the code on my client which fires the method :
JobStorage.Current = new SqlServerStorage("db_connection", new SqlServerStorageOptions
{
PrepareSchemaIfNecessary = true,
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(60)
}).UseRabbitMq(conf =>
{
conf.HostName = RabbitMQ_Hostname;
conf.Port = RabbitMQ_Port;
conf.Username = RabbitMQ_Username;
conf.Password = RabbitMQ_Password;
conf.VirtualHost = RabbitMQ_VirtualHost;
}, new string [] { "default", "queue" });
// Fire method to HangFire
var client1 = new BackgroundJobClient();
var state1 = new EnqueuedState("queue");
client1.Create(() => ConvertVideo(source, target, format), state1);
Can anyone tell me what is wrong with my code ?