I created a HangFire server with HangFire.Core v1.72 , HangFire.SqlServer v1.72, HangFire.AspNet v0.2.0 and HangFire.SqlServer.RabbitMq v1.60 on web Asp.Net framework.
When i try to use rabbitmq as queue it throws an error. Does anyone know what is the cause ?
Below is my code :
public partial class Startup
{
private IEnumerable<IDisposable> GetHangfireServers()
{
var options = new BackgroundJobServerOptions
{
ServerName = "1." + String.Format("{0}.{1}", Environment.MachineName, Guid.NewGuid().ToString()),
Queues = new[] { "critical", "default" }
};
var sqlStorage = new SqlServerStorage("db_connection", new SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true,
UsePageLocksOnDequeue = true,
DisableGlobalLocks = true
}).UseRabbitMq(conf => conf.HostName = "localhost"; conf.Port = 5672; conf.Username = "guest"; conf.Password = "guest"; , "default");
GlobalConfiguration.Configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseStorage<SqlServerStorage>(sqlStorage);
yield return new BackgroundJobServer(options);
}
public class CustomAuthorizeFilter : IDashboardAuthorizationFilter
{
public bool Authorize([NotNull] DashboardContext context)
{
//var httpcontext = context.GetHttpContext();
//return httpcontext.User.Identity.IsAuthenticated;
return true;
}
}
public void Configuration(IAppBuilder app)
{
app.UseHangfireAspNet(GetHangfireServers);
// 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() }
});
}
}
Error is thrown as below :
System.TypeLoadException
HResult=0x80131522
Message=Method ‘GetEnqueuedJobIds’ in type ‘Hangfire.SqlServer.RabbitMQ.RabbitMqMonitoringApi’ from assembly ‘Hangfire.SqlServer.RabbitMq, Version=1.6.0.0, Culture=neutral, PublicKeyToken=null’ does not have an implementation.
Source=Hangfire.SqlServer.RabbitMq
StackTrace:
at Hangfire.SqlServer.RabbitMQ.RabbitMqJobQueueProvider…ctor(IEnumerable1 queues, ConnectionFactory configureAction) at Hangfire.SqlServer.RabbitMQ.RabbitMqSqlServerStorageExtensions.UseRabbitMq(SqlServerStorage storage, Action
1 configureAction, String[] queues)
at HangFireServer.Startup.d__10.MoveNext() in C:\Users\roti\source\repos\HangFireServer\HangFireServer\Startup.cs:line 27
at Hangfire.HangfireAspNet.StartInstances(Func1 configuration) at Hangfire.HangfireAspNet.Use(Func
1 configuration)
at Hangfire.HangfireAspNet.UseHangfireAspNet(IAppBuilder builder, Func`1 configuration)
at HangFireServer.Startup.Configuration(IAppBuilder app) in C:\Users\roti\source\repos\HangFireServer\HangFireServer\Startup.cs:line 65