Compiling the sample Java class user exits (UNIX and Linux®)

The CDC Replication Engine for InfoSphere® DataStage® provides sample custom data formats that you can extend or modify to suit your environment.

About this task

The samples are found in samples.jar, which is located in the samples directory in your CDC Replication Engine for InfoSphere DataStage installation directory. The file contains the following samples:

  • SampleDataStageDataFormat.java—Formats the data suitable for the IBM® DataStage sequential file reader and column importer stages. This sample is located in com.datamirror.ts.userexit.sample.

Note the following:

  • To run the sample custom data formats without modifying them, you must specify the fully qualified path to the compiled custom data formats in Management Console. For example, com.datamirror.ts.target.publication.userexit.sample.UserExitSample.
  • Compiled sample custom data formats are located in the ts.jar file which is found in the lib directory in your CDC Replication Engine for InfoSphere DataStage installation directory. Note that the compiled custom data formats in the ts.jar file have a *.class extension.
  • If you want to modify the sample custom data formats, you must compile the custom data formats after you make changes to the source code.
  • The custom data formats class must also be in your classpath.
  • When the Java class is modified or changed, the CDC Replication Engine for InfoSphere DataStage instance must be restarted to pick up the changed user exit.

Procedure

  1. Stop CDC Replication.
  2. Unzip the samples.jar file into the lib directory in your IBM Data Replication installation directory. Make sure you maintain the directory structure when unzipping the jar file.
    After unzipping the jar file, you will have a directory structure like the following:
    <installation_directory>/lib/com/datamirror/ts/target/publication/userexit/sample
  3. Make your changes to the sample custom data format.
  4. Compile the modified custom data format. For example, if you want to compile UserExitSample.java, open a command window, navigate to the lib folder and issue the following command:
    javac  -classpath ts.jar:. com/datamirror/ts/target/publication/userexit/sample
    /UserExitSample.java

    If this command runs successfully, there will be no output on your screen.

    Prerequisite: Your system must have the Java™ JDK to run this command.
    Note: It is recommended that you compile user exits with Java 8. Support for compiling user exits with Java 7 is deprecated and might be removed in the future. Compiling user exits with Java 6 and lower is not supported.
  5. After running the command successfully, navigate to the following directory and confirm that you have created a UserExitSample.class file:
    <installation_directory>/lib/com/datamirror/ts/target/publication/userexit/sample
  6. Start CDC Replication.
  7. The final step to configure the custom data format is to specify the fully qualified path to UserExitSample in Management Console. For example:
    com.datamirror.ts.target.publication.userexit.sample.UserExitSample
    Note: Do not specify the .class extension.
  8. Compile commands in User Exit documentation in Unix or Linux operating systems for different engines use following commands:
    javac -classpath ts.jar:.
            com/datamirror/ts/target/publication/userexit/sample/UserExitSample.java
    Validating this internally there is additional jar which would be included in aforementioned command or use "*" to use all files in the current lib directory either use:
    javac -classpath ts.jar:user-exit-xxxx.jar
            com/datamirror/ts/target/publication/userexit/sample/UserExitSample.java
    Or
    javac -cp "*"
            com/datamirror/ts/target/publication/userexit/sample/SampleDataStageDataFormat.java

What to do next

Sample Java class user exits are also provided with CDC Replication. You can extend or modify these samples to suit your environment.
Note: When the Java class is modified or changed, the CDC Replication instance must be restarted to pick up the changed user exit.
Note: If you plan to use the sample custom data formats in production environments, you will have to test the samples before they are deployed. IBM does not assume responsibility for adverse results caused by modified or customized custom data formats.