Configuring the iWay Informix CDC Agent

Topics:

iWay Informix CDC Agent listens and reads the Informix Logical Log for INSERT, UPDATE, DELETE records using the Informix Change Data Capture (CDC) API.

Running the iWay Informix CDC Agent Application

Topics:

The iway_runcdc.sh startup script is used to execute the iWay Informix CDC Agent application. The following command structure must be used to execute the iway_runcdc.sh script:

iway_runcdc.sh -E <cdc_env_file> -S <subscr_name> -L <LSN
param>

where:

<cdc_env_file>

Is the full path to the iWay CDC environment file (iwaycdc.env).

<subscr_name>

Is the predefined subscription name.

<LSN param>

Can be either 0 (zero), if you are starting new CDC session, a Last Sequence Number (LSN) using the <log id>:0x<position> format, or the keyword resume, which automatically retrieves the LSN from the subscription control file.

For example:

iway_runcdc.sh -E /home/iwayqa/cdcagent/config/iwaycdc.env –S subscr001 –L 0

You can check if the Informix CDC is running by grepping for the process:

 $ ps -ef | grep iwaycdc

Understanding the iWay CDC Environment File (iwaycdc.env)

The iWay CDC environment file (iwaycdc.env) is passed to the iway_runcdc.sh startup script as a parameter. By executing this environment file, the iWay Informix CDC Agent application sets the general global environment variables for the iWay Informix CDC instance.

The CDC_HOMEDIR variable must be set in the iwaycdc.env file. All remaining variables have default values, but are also configurable:

  • CDC_BINDIR
  • CDC_CONFIGDIR
  • CDC_OUTPUTDIR
  • CDC_LOGDIR
  • CDC_TRACEDIR
  • CDC_ARCHIVEDIR
  • CDC_CONTROLDIR

File names and extensions include .env, .txt, .ctr, .trc, .lsn, and .seq.

Shutting Down the iWay Informix CDC Agent Application

The InformixLEAShutdown.sh script is used to shut down the iWay Informix CDC Agent and all of its processes. The InformixLEAShutdown.sh script calls a C binary program, which can either stop the logging process and completely shut down the agent or just stop the agent.

Based on your requirements, the following methods are available to shut down the iWay Informix CDC Agent:

  • If you need to alter an existing table that is a part of the subscription, you must execute the shut down script using the nologging option. This option disables logging on all tables and allows for any alter tables. Enter the following command to execute the shut down script using the nologging option:
    $ ./informixLEAShutdown.sh nologging

    The following message is logged to the command window:

    iwaycdcagent will be brought down and the logging will be turned off to allow Informix table changes
  • If you need to shut down the iWay Informix CDC Agent and leave full row logging enabled for the table, you must execute the shut down script with no parameters. You can use this option to test INSERT, UPDATE, DELETE operations for replication if the iWay Informix CDC Agent is not running. In order for these updates to be captured, full row logging must be enabled for the table. Executing the shut down script with no parameters ensures that the iWay Informix CDC Agent is shut down, but full row logging is still enabled. Enter the following command to shut down the iWay Informix CDC Agent and leave logging enabled:
    $ ./informixLEAShutdown.sh

    The following message is logged to the command window:

    ./informixLEAShutdown.sh starting
    iwaycdcagent will be brought down but logging will remain on.
    iwaycdcagent has been brought down successfully with logging on

Note: If the iWay Informix CDC Agent unexpectedly shuts down, you will need to restart it using the -RESUME command to ensure that all records are picked up from the Last Sequence Number (LSN).

iWay Informix CDC Agent Output File

The output file that is generated by the iWay Informix CDC Agent is a text file containing XML data. There is a predefined XML format for every supported transaction record type:

  • BEGIN_TX
  • COMMIT_TX
  • ROLLBK_TX
  • INSERT_TX
  • UPDBEF_TX
  • UPDAFT
  • DELETE_TX

The following is a sample XML record for the BEGIN_TX record type:

<transaction database="stores" table="informix.manufact" type="BEGIN_TX" lsn="52:0x14965bc" transactionid="25" transactiontime="2009-12-14 16:46:17"></transaction>

The following is a sample XML record for the COMMIT_TX record type:

<transaction database="stores" table="informix.manufact" type="COMMIT_TX" lsn="52:0x14968bc" transactionid="25" transactiontime="2009-12-14 16:46:17"></transaction>

The following is a sample of an INSERT transaction record in XML format:

<transaction database="stores" table="informix.customer" type="INSERT" lsn="52:0x1496624" transactionid="25"><column name="customer_num" type="SQLINT" key="true "><![CDATA[259]]></column><column name="fname" type="SQLCHAR" key="false"><![CDATA[John           ]]></column><column name="lname" type="SQLCHAR" key="false"><![CDATA[King      ]]></column><column name="company" type="SQLCHAR“ key="false"><![CDATA[iWay          ]]></column><column name="address1" type="SQLCHAR" key="false"><![CDATA[2 Penn Plaza ]]></column><column name="address2" type="SQLCHAR" key="false"><![CDATA[Madison Sq. Garden  ]]></column><column name="city" type="SQLCHAR" key="false"><![CDATA[New York    ]]></column><column name="state" type="SQLCHAR" key="false"><![CDATA[NY]]></column><column name="zipcode" type="SQLCHAR" key="false"><![CDATA[10121]]></column><column name="phone" type="SQLCHAR" key="false"><![CDATA[222-333-4444      ]]></column></transaction>

iWay Informix CDC Agent Data File Name

iWay Informix CDC Agent writes the XML CDC data into a text file. The CDC data file name has the following format:

{$ CDC_BASENAME}_{$ CDC_SUBSCR_NAME}_YYYYMMDD_NNNN.${ CDC_OUT_EXT}

where:

CDC_BASENAME

Is the program name. The environment variable is set in the iwaycdc.env file (default) located in the config directory.

CDC_SUBSCR_NAME

Is the subscription name. The environment variable is set in the subscrname.env file located in the config directory. It is passed to the iwaycdcagent program as an argument with the -S command line option.

YYYYMMDD

Is the current date when the CDC data file is created.

NNNN

Is the serial four-digit number. Starts with 0001, left padded by 0. Increments for a duration of the day, specified in the DATE above. Resets to 0001 at 00:00 am along with a new DATE, when a new CDC data file is created.

CDC_OUT_EXT

Is the extension of the CDC data file (.txt by default). The environment variable is set in the iwaycdc.env file (default) located in the config directory.

For example:

iwaycdc_subscr01_20091214_0015.txt

The CDC data files are located in the following directory (separate for every subscription):

${CDC_OUTPUTDIR}/${ CDC_SUBSCR_NAME}

iWay Informix CDC Agent Trace File Name

iWay Informix CDC Agent Trace File Name has the same format as the CDC data file, but only uses a different extension.

The trace file extension (.trc by default) is set as an environment variable in the iwaycdc.env file (default) located in the config directory.

The trace files are located in the following directory (separate for every subscription):

${CDC_OUTPUTDIR}/${ CDC_SUBSCR_NAME}