You need to sign in to do that
Don't have an account?
Vishant Shah
Scheduling batch jobs
Hi,
I've got a scheduled job for invoicing, using financial force, which starts off a batch job based on SOQL query filters, When this batch job finishes, there is a check to see if there are any more records that need processing and executes the same batch using database.execute.
when the first batch runs the process finishes quite fast, but the next batch takes about 5 minutes to process. I am aware that the batch execution is dependant on salesforce resources, but 5 minutes is too long. I've tried rescheduling instead of executing the batch but this takes similar amount of time.
Is there a optimised or a better solution to do this sort of thing. this is the piece of code in my finish method of the batchable class.
Datetime sysTime = System.now().addSeconds( 10 );
String chronExpression = '' + sysTime.second() + ' ' + sysTime.minute() + ' ' + sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year();
AutoInvoiceSchedule aib = new AutoInvoiceSchedule();
System.schedule( 'EmailInvoicesBatchSchedule ' + sysTime, chronExpression, aib );
Look forward to your replies.
Thanks
Vishant
I've got a scheduled job for invoicing, using financial force, which starts off a batch job based on SOQL query filters, When this batch job finishes, there is a check to see if there are any more records that need processing and executes the same batch using database.execute.
when the first batch runs the process finishes quite fast, but the next batch takes about 5 minutes to process. I am aware that the batch execution is dependant on salesforce resources, but 5 minutes is too long. I've tried rescheduling instead of executing the batch but this takes similar amount of time.
Is there a optimised or a better solution to do this sort of thing. this is the piece of code in my finish method of the batchable class.
Datetime sysTime = System.now().addSeconds( 10 );
String chronExpression = '' + sysTime.second() + ' ' + sysTime.minute() + ' ' + sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year();
AutoInvoiceSchedule aib = new AutoInvoiceSchedule();
System.schedule( 'EmailInvoicesBatchSchedule ' + sysTime, chronExpression, aib );
Look forward to your replies.
Thanks
Vishant
In general, A batch with low set of records may take long time as compared to batch with large set of records. This is because the general use case of batch apex is to process large number of records faster. Since there is no SLA on asynchronous processes in Salesforce, I'm unable to think of anny other workaorunds. Also, here's some documentation: https://help.salesforce.com/apex/HTViewSolution?urlname=Inconsistent-Behavior-of-Batch-Jobs&language=en_US
If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.
Thanks,
Shashank
All Answers
In general, A batch with low set of records may take long time as compared to batch with large set of records. This is because the general use case of batch apex is to process large number of records faster. Since there is no SLA on asynchronous processes in Salesforce, I'm unable to think of anny other workaorunds. Also, here's some documentation: https://help.salesforce.com/apex/HTViewSolution?urlname=Inconsistent-Behavior-of-Batch-Jobs&language=en_US
If this answers your question, please mark this as the Best Answer for this post, so that others can benefit from this post.
Thanks,
Shashank
thank you for the prompt answer. I have implemented a workaround for this, Used bulk methods instead of using normal record processing
Regards
Vishant