I have one big job, code :
public class TbcMailSender : IJob
{
public void Execute(IJobExecutionContext context)
{
using(EFDbContext _db = new EFDbContext()){
_db.JobTests.Add(new JobTest
{
Name = "trigger",
JobDate = DateTime.Now
});
_db.SaveChanges();
var parserHelper = ParserHelper.GetParserHelper(_db);
try
{
parserHelper.Bfm();
}
catch (Exception)
{
}
try
{
parserHelper.Bpn();
}
catch (Exception)
{
}
try
{
parserHelper.Commersant();
}
catch (Exception)
{
}
try
{
parserHelper.Ghn();
}
catch (Exception)
{
}
try
{
parserHelper.Ipn();
}
catch (Exception)
{
}
try
{
parserHelper.PirveliRadio();
}
catch (Exception)
{
}
try
{
parserHelper.Forbes();
}
catch (Exception)
{
}
try
{
parserHelper.Marketer();
}
catch (Exception)
{
}
}
}
}
Each method needs about 2-3 minutes (Bfm, Bpn... Marketer). In future i'll add more methods and is it possible that last method would not trigger or quartz job would bug? Which is better , perfom one big job or devide it to multiple small jobs.
Quartz can handle jobs that run for a very long time. But you might run into situations where it runs so long that another job instance fires before one finishes.
You'll have to decide if it's okay or not to split up the work into multiple jobs based on how tightly coupled the work is. For example, given three tasks: A, B, and C. If these tasks must be executed in a particular order then it won't make sense to have individual Quartz jobs because there is no guarantee that they'll fire and execute in the correct order.
If you really want to isolate the work into their own clean atomic units, then I suggest implementing some sort of message queue. The job can queue task A. As task A finishes it is responsible for queuing task B, and so on. This ensures that each task is executed once and in order.