Right out-of-the box, custom processing engine tasks may be created without having to write new Java components. These tasks are application components that implement common functionalities. There are several base processing engine tasks that are also based on these common tasks. Built-in processing engine tasks are limited in scope and functionality to what they’re capable of and cannot be extended or changed.
Script Task
A script task is a processing engine task that executes a SQL script. A ScriptTask takes a single parameter, the name of the SQL script, and executes it on the target database, which could be one or more depending on the definitions in the script. This processing engine task requires that the SQL script file is located in the application classpath (typically it is /WEB-INF/classes). Below is an example of a custom script task definition:
<!-- ====== Section 3: Custom task definitions ========================= -->
<bean id="lgeExtension6"
parent="trmScriptTask"
scope="prototype">
<property name="scriptFileName" value="lgeExtension6.sql"/>
</bean>
Name |
Java Class Name |
ScriptTask |
com.teradata.trm.pe.common.task.ScriptTask |
Patameters |
Required (Y/N) |
scrptFileName |
Y |
Parameter Substitution
At runtime, the processing engine automatically substitutes values for the given set of parameters. These parameters may be used in the SQL script:
Parameter |
Description |
Processing Engine Properties |
@ProcessingEngineId |
The processing engine ID |
@RunId |
The processing engine run ID |
@JobId |
The processing engine job ID |
@JobHistoryID |
The processing engine job history ID |
@DefaultSchemaId |
The ID of the schema associated with the processing engine |
@WorkingPartitionId |
The working partition ID. This value is unique for every run of the processing engine job |
@ObjectId |
The 12-char ID of the (single) object associated with the job. This is only available for single, adhoc jobs |
Setting Parameters (used by batch engine) |
@ProcessDttm |
The process dttm/selection dttm/run date |
@ProcessingPeriodId |
The processing period ID |
@EventProcessingId |
The event processing ID, if available |
@ResponseProcessingCd |
The response processing code, if available |
Database Names Parameters |
@Definition |
The data definition database, application database |
@SpindleTemp |
The temp spindle database |
@CommonSpindleTemp |
The common temp spindle database |
@Spindle |
The spindle database |
@CommonSpindle |
The common spindle database |
@Metadata |
Used to reference Metadata tables such as MD_TABLE, etc |
@All_Spindle_Elements |
Returns fields, indexed or otherwise, found in the lead database (i.e. Household, Individual, Account in the Customer schema) |
@Spindle_Index_Elements |
Returns all fields, including completing fields, for a specific lead database (i.e. Household_Id, Individual_Id in the Customer schema) |
Below is an example SQL script that uses some of these parameters:
LOCKING "@SpindleTemp".LH_RUN_HISTORY FOR ACCESS
LOCKING "@Definition".CM_COMMUNICATION FOR ACCESS
UPDATE "@CommonSpindle".RT_PACKAGE_COUNT
SET Package_Cnt = 0
WHERE Communication_Id IN (
SELECT
RH.Communication_Id
FROM
"@SpindleTemp".LH_RUN_HISTORY RH
JOIN
"@Definition".CM_COMMUNICATION C
ON
RH.Communication_Id = C.Communication_Id AND
RH.Process_Dttm = CAST('@ProcessDttm' AS TIMESTAMP) AND
RH.Run_Id = '@RunId'
WHERE
C.Status_Cd = 1
)
Process Executor Task
ProcessExecutorTask is a processing engine task that executes a given batch or script command in the operating system. This task takes a script file and runs the commands in it in a dedicated command shell, in the process causing the current thread to wait, if necessary, until the process has terminated. The ProcessExecutor task requires that the script file resides in the application classpath. Below is an example definition:
<!-- ====== Section 3: Custom task definitions ========================= -->
<bean id="lgeExtension7"
class="com.teradata.trm.pe.common.task.ProcessExecutorTask"
scope="prototype">
<property name="command" value="myexecutable.bat"/>
</bean>
Name |
Java Class Name |
ProcessExecutorTask |
com.teradata.trm.pe.common.task.ProcessExecutorTask |
Patameters |
Required (Y/N) |
command |
Y |
Output |
Type |
Exit value of the process |
Integer (java.lang.Integer)
0 - indicates normal termination or success
1 - indicates abnormal termination or failure |
SimpleMessage Task
SimpleMessage task is a processing engine task used to log messages in the processing engine logs. Logging the specified message is the only functionality provided by this task. As such, this task may be used to facilitate information logging at runtime. Since there is no functional behavior such as database access or query execution, this task may be used to log specific messages as a way of checking the sequence of processing engine steps. In short, this is a good candidate for testing customizations. Here is the definition of this task:
<!-- ====== Section 3: Custom task definitions ========================= -->
<bean id="lgeExtension8"
class="com.teradata.trm.pe.common.task.SimpleMessageTask"
scope="prototype">
<property name="message" value="This is a test message."/>
</bean>
Name |
Java Class Name |
SimpleMessageTask |
com.teradata.trm.pe.common.task.SimpleMessageTask |
Patameters |
Required (Y/N) |
message |
Y |
If the above example is added to a processing engine customization, the message “This is a test message.” should show up in the processing engine log:
2008-11-18 14:43:47,968 :[pool-1-thread-1] Dispatching Task: lgeExtension8
2008-11-18 14:43:47,984 :[pool-1-thread-2] Task lgeExtension8 boundary start: Remaining system memory before = 421681760
2008-11-18 14:43:47,999 :[pool-1-thread-2] This is a test message.
2008-11-18 14:43:48,015 :[pool-1-thread-2] Task lgeExtension8 boundary end: Remaining system memory after = 421350144
HTTPRequester Task
HttpRequester task is a processing engine task that accesses a web URL. This task opens an HTTP request to the remote or local web endpoint and logs the contents of the HTTP response to the processing engine log. The provided address must be a fully-qualified web URL.
<!-- ====== Section 3: Custom task definitions ========================= -->
<bean id="lgeExtension9"
class="com.teradata.trm.pe.common.task.HttpRequesterTask"
scope="prototype">
<property name="url" value="http://www.teradata.com"/>
</bean>
Name |
Java Class Name |
HttpRequesterTask |
com.teradata.trm.pe.common.task.HttpRequesterTask |
Patameters |
Required (Y/N) |
url |
Y |
Any error that occurred as a result of web access will lead to the failure of the task and subsequent failure of the processing engine job as a whole.