StartBatchJob is used to manually start a Batch Job. This service takes as input the name of the BatchJob you wish to start. This is not case sensitive. If the specified BatchJob does not exist, an exception is thrown.
Batch Jobs are processes that can be scheduled to run. They run outside of user interaction and are not initiated by button clicks or page loads like most processes unless you use StartBatchJob.
For example, if a user clicks a button that updates a database record and the process of doing this update takes five minutes, the site will wait for the process to finish before forwarding the user to the next page. This can be a problem because the user will be stuck waiting for the process to finish. This is also an issue because the page will only wait so long before it times out. StartBatchJob can be used to eliminate this problem because the Batch Job will run in the background once it is kicked off by the service.
This is useful in situations where you want to manually start a Batch Job because some business requirement will not allow you to schedule the Batch Job to run at the same time every day or every week, or in a case where the Job needs to run now but its not scheduled to run until late in the night.
StartBatchJob Output Cases
Successfully Starting a BatchJob
When successfully starting a BatchJob, it will return the following outputs:
Starting a BatchJob That Was Already Running
Starting a BatchJob That Doesn’t Exist
In this example, the StartBatchJob service was used to start a batch job which does not exist. This threw an exception, shown below.
This error tells you that it is trying to find the BatchJob “natestestbatch2” but it could not, you can see that in the message after Id requested.