Running Jobs
If you want to run a PDI job from Java code in a stand-alone application, take a look at this sample class,
org.pentaho.di.sdk.samples.embedding.RunningJobs
. It sets the parameters and executes the job in etl/parametrized_job.kjb. The job can be run from the .kjb file using runJobFromFileSystem()
or from a repository using runJobFromRepository()
.- Always make the first call to
KettleEnvironment.init()
whenever you are working with the PDI APIs.. - Prepare the job. The definition of a PDI job is represented by a
JobMeta
object. You can load this object from a .ktb file, a PDI repository, or you can generate it dynamically. To query the declared parameters of the job definition uselistParameters()
. To set the assigned values usesetParameterValue()
. - Execute the job. An executable
Job
object is derived from theJobMeta
object that is passed in to the constructor. TheJob
object starts, and then executes in a separate thread. To wait for the job to complete, callwaitUntilFinished()
. - Evaluate the job outcome. After the
Job
completes, you can access the result usinggetResult(
). TheResult
object can be queried for success usinggetResult()
. This method returnstrue
on success andfalse
on failure. To get more information, retrieve the job log lines.