Developing transactionally consistent consumer applications for the CDC Replication Engine for Kafka (UNIX and Linux)

You can include the transactionally consistent consumer in custom Java applications that work with the CDC Replication Engine for Kafka.

About this task

You can modify the transactionally consistent consumer applications that are provided with the CDC Replication Engine for Kafka to suit your needs or use them as samples to create custom applications.

Procedure

  1. Extract the txnconsumer-applications-samples-*-sources.jar file into the /lib directory in your CDC Replication Engine for Kafka installation directory.
    cd CDC_Kafka_installation_directory/lib
    cat txnconsumer-applications-samples-*-sources.jar | jar -xv
  2. Locate the sample transactionally consistent consumer applications in CDC_Kafka_installation_directory/lib/com/datamirror/ts/kafka/ and find an application that you want to use as a sample.
  3. Rename the sample class and .java file so that they differ from the existing sample .java file.
  4. Modify the .java file.
  5. Compile the user-defined .java file.
    javac -classpath "CDC_Kafka_installation_directory/lib/*" CDC_Kafka_installation_directory/lib/com/datamirror/ts/kafka/txconsistentconsumer/sampleapplications/user-defined-application.java
  6. Confirm that a .class file was created in the directory where the user-defined .java file resides.
    ls CDC_Kafka_installation_directory/lib/com/datamirror/ts/kafka/txconsistentconsumer/sampleapplications
    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.
  7. Call the application from the /lib directory in your CDC Replication Engine for Kafka installation directory.
    cd CDC_Kafka_installation_directory/lib
    java -cp "*" com.datamirror.ts.kafka.txconsistentconsumer.sampleapplications.application name -cs commit stream topic name -c consumer configuration file name
    Note: Adding libraries to the CLASSPATH that conflict with libraries that are provided with the CDC Replication Engine for Kafka is not supported.