Thursday, November 17, 2011

Passing Initialization Parameters via tdisrvctl


I found the following process to work if you want to pass initialization parameters to a connector, via the command line.

For further details on parameters used for the 'tdisrvctl' command, refer to the docs.
Due to an APAR with the 'tdisrvctl' utiltity, you will need to be at TDIv7.1 FP0006 for the '-alop' parameter to parse correctly.


1.  Use the 'op-entry' object in the connector's configuration to access the passed in value.
All initialization attributes are to be prefixed with $init





























2.  When calling the 'tdisrvclt' utility,  use the '-alop' parameter to pass the value pairs to the server.
You can refer to the documentation link above for further details about this parameter.

Syntax:
bin\tdisrvctl -p 1099 -K serverapi\testadmin.jks
-P administrator -T testserver.jks -W server -op start -c config.xml -r SampleAL -alop $initialize {parameter:value;parameter:value}

Windows Exmaple:
\bin\tdisrvctl -p 1099 -K serverapi\testadmin.jks -P administrator -T testserver.jks -W server -op start -c config.xml -r SampleAL-alop $initialize {$init.oraId:oradmin;$init.oraPwd:abc123}

Linux Example:
./bin/tdisrvctl -p 1099 -K serverapi/testadmin.jks -P administrator -T testserver.jks -W server -op start -c config.xml -r SampleAL -alop \$initialize '{$init.oraId:oradmin;$init.oraPwd:abc123}'


------
Passing Initialization Parameters to the startAL() method via the tdisrvctl utility:
Here's a simple AL with the following in the AL Prolog.

//------------------------------------------------//
var stats;
var error;
var num;
var adds;
var result;

var OpEntry = task.getOpEntry();
var tcb = system.newTCB();

tcb.setConnectorParameter ( "JDBCconnector", "jdbcLogin", OpEntry.getString("$init.oraId"));
tcb.setConnectorParameter ( "JDBCconnector", "jdbcPassword", OpEntry.getString("$init.oraPwd"));

task.logmsg("**** Check Emp Status ******");
var check = main.startAL("AL1",tcb);
check.join();
result = check.getResult();
stats = task.getStats();
error=stats.getError();
num=stats.numErrors();

if (num == 0 ){
    task.logmsg("**** Running Emp Update ******");
    var empUpdate = main.startAL("AL2",tcb);
    empUpdate.join();
    result = empUpdate.getResult();
    stats = task.getStats();
    error=stats.getError();
    num=stats.numErrors();
    adds=stats.numAdd();

    task.logmsg("stats are: "+stats);
    task.logmsg("error is "+error);
    task.logmsg("numerrors is "+num);  
    task.logmsg("**** Run complete ******");
}else{
task.logmsg("**** Run ended ******");
        task.exit
}
//------------------------------------------------//


Commandline Command:

bin\tdisrvctl -p 1099 -K serverapi\testadmin.jks
-P administrator -T testserver.jks -W server -op start -c config.xml -r SampleAL -alop $initialize {parameter:value;parameter:value}