Db2 to Kafka replication - connect_cdc_sqdata - Latest

Connect CDC (SQData) Apply engine

Product type
Software
Portfolio
Integrate
Product family
Connect
Product
Connect > Connect CDC (SQData)
Version
Latest
Language
English
Product name
Connect CDC (SQData)
Title
Connect CDC (SQData) Apply engine
Copyright
2024
First publish date
2000
ft:lastEdition
2024-07-30
ft:lastPublication
2024-07-30T20:19:56.898694
Replicate Db2 changed data (CDC) for the IVP EMPLOYEE and DEPARTMENT tables into unique JSON formatted Kafka Topics with default partitioning. The example also includes a filter for the EMPLOYEE table. Only updates to employees with a bonus over $5,000 will cause the record to be written to Kafka. All changes to the DEPT table are Replicated with no filter applied.
----------------------------------------------------------------------
-- Name: DB2TOKAF:  Z/OS DB2 To Kafka JSON on Linux
-- Client/Project: client/project
----------------------------------------------------------------------
--  SUBSTITUTION PARMS USED IN THIS SCRIPT:
--    %(ENGINE) - ENGINE Name
--    %(SHOST) - Source HOST of the Capture/Publisher
--    %(SPORT) - Source HOST SQDaemon PORT
--    %(PUBNM) - Source Capture/Publisher Agent Name
----------------------------------------------------------------------
--       Change Log:
----------------------------------------------------------------------
-- 2019-02-01 INITIAL RELEASE using JSON
----------------------------------------------------------------------
JOBNAME DB2TOKAF;
OPTIONS
   CDCOP('I','U','D')                 -- Set CHANGE OP Constants
  ,USE AVRO COMPATIBLE NAMES           -- Recommended for JSON
;
----------------------------------------------------------------------
--       Data Definition Section
----------------------------------------------------------------------
----------------------------------------------------------------------
--       Source Descriptions
----------------------------------------------------------------------
BEGIN GROUP DB2_SOURCE;
DESCRIPTION DB2SQL ./DB2DDL/EMP.ddl AS EMPLOYEE
          KEY IS EMP_NO;
DESCRIPTION DB2SQL ./DB2DDL/DEPT.ddl AS DEPARTMENT
          KEY IS DEPT_NO;
END GROUP;
----------------------------------------------------------------------
--       Target Descriptions
----------------------------------------------------------------------
-- None required
----------------------------------------------------------------------
--       Datastore Section
----------------------------------------------------------------------
----------------------------------------------------------------------
--       Source Datastore
----------------------------------------------------------------------
DATASTORE cdc://%(SHOST):%(SPORT)/%(PUBNM)/%(ENGINE)
        OF UTSCDC
        AS CDCIN
        DESCRIBED BY GROUP DB2_SOURCE
;
----------------------------------------------------------------------
--       Target Datastore(s)
----------------------------------------------------------------------
DATASTORE kafka:///*/key                   -- specify dynamic topic
        OF JSON                           -- specify JSON format
        AS TARGET
        DESCRIBED BY GROUP DB2_SOURCE     -- use source for REPLICATE
;
----------------------------------------------------------------------
--       Field Specification Section
----------------------------------------------------------------------
DATEFORMAT 'ISOIBM';
----------------------------------------------------------------------
--       Procedure Section
----------------------------------------------------------------------
CREATE PROC P_EMPLOYEE AS SELECT
{
  IF EMPLOYEE.BONUS > '5000'
  {
REPLICATE(TARGET, EMPLOYEE)
  }
}
FROM CDCIN;
----------------------------------------------------------------------
--       Main Section
----------------------------------------------------------------------
PROCESS INTO TARGET
SELECT
{
CASE RECNAME(CDCIN)
WHEN 'EMP' CALLPROC(P_EMPLOYEE)
WHEN 'DEPT' REPLICATE(TARGET, DEPARTMENT)
}
FROM CDCIN;