Top
Top
LibraryEASYProcess Reference Manual 5ProcessesServicesBatchJobWorkshopStartBatchJob

StartBatchJob Overview

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 Use Examples
StartBatchJob Output Cases
Workshop:BatchJobWorkshop
Service:StartBatchJob
Inputs
NameThis is the name of the Batch Job you will be running, the name is not case sensitive. The Batch Job needs to have already been set up prior to running this service.

Outputs
RunningReturns True if the Batch is started successfully, False if the Batch is unsuccessful at starting.
WindowsProcessIdThis ID is the PID in the Task Manager, under Details, related to this batch running. It is assigned by the Windows machine.

StartBatchJob Use Examples

Basic StartBatchJob use

In this example we have three services, one service will get the status of the Batch Job to see if it is running, the StartBatchJob service which will start the batch job, and another service to get the status to show that the Batch Job has started and is running.

Here we have the input to the StartBatchJob service

When we run these three services and view the logs we will see that the first GetStatus has running coming back as “False”

You will also notice that the WindowsProcessId returned wont match the value returned in the StartBatchJob service. That is because GetStatus will get the status of the most current Batch that ran, even if the Batch has stopped.

We will now see the output of the StartBatchJob service with a running of “True” and a new WindowsProcessId (PID)

We can now check the Windows Task Manager to see if the PID matches to a Batch Job running.

As you can see it does.

Next we will view the output from GetStatus showing the WindowsProcessId matching our new Id and the running flag coming back as “True”

Example from Work With Batch Jobs

In this example we have a WebPart that has a list section of all of our Batch Jobs, in the list section there is a run button

In the process of the run button we have three services, one that pulls the values from the page (the important value being the “Name”), the StartBatchJob service, and a service that will refresh the page.

In PreValues a field named Instance is placed into a variable named Instance, in this case Instance is the name.

In the StartBatchJob service we use the Instance value set up in PreValues to start the Batch Job

This shows us that we can set up a Page, in this case “Work With Batch Jobs”, that allows the user to run a batch job by clicking a button using the StartBatchJob service.


StartBatchJob Output Cases

Successfully Starting a BatchJob

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

Running

True

WindowsProcessId

[WindowsProcessId]

Starting a BatchJob That Was Already Running

Running

True

WindowsProcessId

[WindowsProcessId]

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.


Powered by EASYProcess (© 2019 K-Rise Systems, Inc).