Developing a user-defined Kafka custom operation processor (UNIX and Linux)

You can create a Kafka custom operation processor (KCOP) that works with the CDC Replication Engine for Kafka on Linux® and UNIX by developing a Java™ class.

About this task

You can modify the integrated KCOPs that are provided with the CDC Replication Engine for Kafka to suit your needs or use them as samples to create user-defined KCOPs. A KCOP must implement the KafkaCustomOperationProcessorIF interface. For more information on the interface, see the API reference in Javadoc format that is installed with the CDC Replication Engine for Kafka.

Procedure

  1. Extract the samples.jar file into the lib directory in your CDC Kafka installation directory.
    $ cd CDC_Kafka_installation_directory/lib
    $ jar xf ../samples/samples.jar
    
    The integrated KCOPs are in CDC_Kafka_installation_directory/lib/com/datamirror/ts/target/publication/userexit/sample/kafka
  2. Find a KCOP to use as a sample. Rename the class and .java file so they do not match any of the integrated KCOP .java files.
  3. Modify the .java file.
  4. Compile the user-defined KCOP .java file by using an IBM® SDK, Java Technology Edition, Version 8.
    $ javac -classpath "CDC_Kafka_installation_directory/lib/*"
    CDC_Kafka_installation_directory/lib/com/datamirror/ts/target/publication/userexit/sample/kafka/user-defined_KCOP.java
  5. Confirm that a .class file was created in the same directory where the user-defined KCOP .java file resides.
    $ cd CDC_Kafka_installation_directory/lib/com/datamirror/ts/target/publication/userexit/sample/kafka
    Note: The files that you generate from compiling the class must be in a library or folder that is referenced by the CLASSPATH environment variable.
  6. Stop the CDC Replication Engine for Kafka datastore.
  7. Start the CDC Replication Engine for Kafka datastore.
  8. Follow steps 1-6 from Enabling integrated Kafka custom operation processors (KCOP).
  9. Enter values for the following fields:
    Class Name
    com.datamirror.ts.target.publication.userexit.sample.kafka.user-defined_KCOP
    Parameters
    The parameters are determined by the user-defined KCOP.
  10. Click OK.
    Note: Adding libraries to the CLASSPATH variable that conflict with libraries that are provided with the CDC Replication Engine for Kafka is not supported.