What is the difference between a Joblet and the tRunJob component
Both Joblet and tRunJob component encourage code reuse and refactoring, help improve the development efficiency and ease the maintenance.
However, you may wonder what is the difference between them, and in which case you should use one or the other. This article explains the differences between a Joblet and the tRunJob component from a technical point of view as well as from a usage angle.
Difference
Talend Studio uses a Java code generator, each Job is translated to a Java class. From a technical point of view, there are two differences:
- The tRunJob component executes a child Job, which is a separate Java class. The main Job instantiates the child Job and executes it using the tRunJob method. A Joblet is just a GUI extraction and refactoring of some components. It creates a reusable transformation, the generated code of Joblet is still a part of the Java class of the main Job.
- The tRunJob component is a different unit of execution and has its own context variables. The child Job, called with the tRunJob in the main Job, can't access the context variables of the main Job. However, a Joblet can access the context variables of the main Job, as it is a part of the main Job.
Usage
Because of the differences between a Joblet and the tRunJob component in the code refactoring and function, the decision of when to use a Joblet or the tRunJob component is based on business requirements. The following explanation describes the circumstances which could lead you to choose one or the other.