EndBatchJob

EndBatchJob

EndBatchJob Overview

EndBatchJob is used to manually end a Batch Job. This service takes as input the name of the BatchJob you wish to end. 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.

 

When working with batch jobs you may encounter situations where you need to end the batch job after a certain record has been processed. in these situations you can use the EndBatchJob service.

For example, consider a batch process which finds the most ordered items for a logged in account. This batch job process could work by running a query against JDE Order History tables for a list of the most ordered items. This query could return a very long list of items. The process would then loop through the results and ask “Is this item in JDE also order-able on the EASYCommerce portal?”. If yes, the item is added to a list of top items for the account. If no, the process looks at the next result from the JDE query and asks the same question. This could continue for a very long time since the query to JDE has very many results. However, the process could be built to continue this process loop until 10 items have been found. At this point, the EndBatchJob service should be run because the desired records were retrieved.

EndBatchJob Output Cases

Successfully Ending a BatchJob

When successfully ending a BatchJob, it will return the following outputs:

Running

False

Ended

True

WindowsProcessId

[WindowsProcessId]

Failure Ending a BatchJob

If the service were to fail ending the batch job without throwing an exception, if would return the following outputs:

Running

True

Ended

False

WindowsProcessId

[WindowsProcessId]

Ending a BatchJob That Wasn’t Running

If you use the EndBatchJob service to end a Batch Job which was not running, it will return the following outputs:

Running

False

Ended

False

WindowsProcessId

[WindowsProcessId] (from the last time the batch job ran)

Ending a BatchJob That Doesn’t Exist

In this example, the EndBatchJob service was used to stop a batch job which does not exist. This threw an exception, shown below.