Hello
I am trying to use HangFire for a function that makes some complex jobs like consuming external webservices, process data and save in database.
Here is my Startup.cs
public class Startup
{
public void Configuration(IAppBuilder app)
{
/// Setting the Pooling interval for SQL Server
var sqlServerOptions = new SqlServerStorageOptions
{
QueuePollInterval = TimeSpan.FromSeconds(15)
};
var queueOptions = new BackgroundJobServerOptions
{
Queues = new[] { "critical", "default" }
};
GlobalConfiguration.Configuration.UseSqlServerStorage("Context", sqlServerOptions);
app.UseHangfireDashboard();
app.UseHangfireServer();
app.UseHangfireServer(queueOptions);
HomeController home = new HomeController();
home.Start();
}
}
And this is the start function
public void Start()
{
CompanyMatch = new CompanyMatchModel();
var LinkedCompList = CompanyMatch.GetLinkedComp();
Context db = new Context();
OrderModel order = new OrderModel();
if (LinkedCompList.Count() != 0)
{
foreach (var companyMatch in LinkedCompList)
{
companyMatch.Company = db.Company.Include(u => User).First(sap => sap.DBName.Equals(companyMatch.Company.DBName));
companyMatch.EcommerceModel = db.Ecommerce.Include(p => p.Platform).First(e => e.SiteName.Equals(companyMatch.EcommerceModel.SiteName));
RecurringJob.AddOrUpdate("ImportTdoBdbId", () => OrderModel.ImportOrdersToDb(companyMatch), "*/3 * * * *");
RecurringJob.AddOrUpdate("UpdateOrdersNfId", () => OrderModel.UpdateOrdersNfeKey(companyMatch.SAPCompany), "*/5 * * * *");
RecurringJob.AddOrUpdate("UpdateXmlSHLId", () => OrderModel.UpdateXmlSHL(companyMatch.SAPCompany), "*/7 * * * *");
}
RecurringJob.AddOrUpdate("ImportOrders", () => order.ImportOrders(), "*/5 * * * *");
}
}
I have added some Debug.Print in the internal functions of those methods and what I noticed is that HangFires pass thru all of them but does not execute the operations. Inside each of the functions added in Queue there are sub functions that collect data, loops to validate them and database insertings.
Does HangFire supports these kinds of operation or it has some limitation in this scenario?