12 Using the Command Event Handler
This chapter describes how to use the Command Event Handler. The Command Event Handler provides the interface to synchronously execute an external program or script.
- Overview - Command Event Handler
The purpose of the Command Event Handler is to load data files generated by the File Writer Handler into respective targets by executing an external program or a script provided. - Configuring the Command Event Handler
You can configure the Command Event Handler operation using the File Writer Handler properties file. - Using Command Argument Template Strings
Command Argument Templated Strings consists of keywords that are dynamically resolved at runtime. Command Argument Templated strings are passed as arguments to the script in the same order mentioned in thecommandArgumentTemplate
property .
12.1 Overview - Command Event Handler
The purpose of the Command Event Handler is to load data files generated by the File Writer Handler into respective targets by executing an external program or a script provided.
Parent topic: Using the Command Event Handler
12.2 Configuring the Command Event Handler
You can configure the Command Event Handler operation using the File Writer Handler properties file.
The Command Event Handler works only in conjunction with the File Writer Handler.
To enable the selection of the Command Event Handler, you must first configure the
handler type by specifying gg.eventhandler.name.type=command
and
the other Command Event properties as follows:
Table 12-1 Command Event Handler Configuration Properties
Properties | Required/ Optional | Legal Values | Default | Explanation |
---|---|---|---|---|
|
Required |
command |
None |
Selects the Command Event Handler for use with Replicat |
|
Required |
Valid path of external program or a script to be executed. |
None |
The script or an external program that should be executed by the Command Event Handler. |
|
Optional |
Integer value representing milli seconds |
Indefinitely |
The Command Event Handler will wait for a period of time for the called commands in the script or external program to complete. If the Command Event Handler fails to complete the command within the configured timout period of time, process will get Abend. |
gg.eventhandler.name.multithreaded |
Optional | true |
false |
true
|
If true, the configured commands in the script or external program will be executed multithreaded way. Else executed in single thread. |
|
Optional |
See Using Command Argument Templated Strings. |
None |
The Command Event Handler uses the command argument template strings during script or external program execution as input arguments. For a list of valid argument strings, see Using Command Argument Templated Strings. |
gg.eventhandler.command.type=command
gg.eventhandler.command.command=<path of the script to be executed>
#gg.eventhandler.command.cmdWaitMilli=10000
gg.eventhandler.command.multithreaded=true
gg.eventhandler.command.commandArgumentTemplate=${tablename},${datafilename},${countoperations}
Parent topic: Using the Command Event Handler
12.3 Using Command Argument Template Strings
Command Argument Templated Strings consists of keywords that are dynamically
resolved at runtime. Command Argument Templated strings are passed as arguments to the
script in the same order mentioned in the commandArgumentTemplate
property
.
The valid tokens used as a command Argument Template strings are as follows:
UUID
, TableName
, DataFileName
,
DataFileDir
, DataFileDirandName
,
Offset
, Format
, CountOperations
,
CountInserts
, CountUpdates
,
CountDeletes
, CountTruncates
. Invalid Templated
string results in an Abend.
Supported Template Strings
- ${uuid}
- The File Writer Handler assigns a uuid to internally track the state of generated files. The usefulness of the uuid may be limited to troubleshooting scenarios.
- ${dataFileDirandName}
- The source file name with complete path and filename along with the file extension.
- ${format}
- The format of the file. For example:
delimitedtext | json | json_row | xml | avro_row | avro_op | avro_row_ocf | avro_op_ocf
- ${countOperations}
- The total count of operations in the data file. It must be either renamed or used by the event handlers or it becomes zero (0) because nothing is written. For example, 1024.
- ${countInserts}
- The total count of insert operations in the data file. It must be either renamed or used by the event handlers or it becomes zero (0) because nothing is written. For example, 125.
- ${countUpdates}
- The total count of update operations in the data file. It must be either renamed or used by the event handlers or it becomes zero (0) because nothing is written. For example, 265.
Note:
The Command Event Handler on successful execution of the script or the commnad logs a message with the following statement: The command completed successfully, along with the statement of command that gets executed. If there's an error when the command gets executed, the Command Event Handler abends the Replicat process and logs the error message.Parent topic: Using the Command Event Handler