Generating Avro Schemas for Apache Kafka Consumers
Generating Avro Schemas for Apache Kafka Consumers
For configurations that have Apache Kafka targets, you can generate and save Avro schema files based on source table schema. You can save the generated text files for later use by Kafka consumers that subscribe to the Kafka topics to which Data Replication writes messages.
Data Replication, as a producer application, also requires an Avro schema file. However, this schema is transparently generated for Data Replication use.
Before you begin, open the configuration and connect to the source database and the Kafka target.
Click
Schema
Generate Schema for the Target
on the menu bar, or click the
Generate Schema for the Target
icon button on the Replication Configurations toolbar.
The
Avro Schema Generation
dialog box appears.
Under
Source/Target
, verify that the
Source
option is selected.
In the
Schema/owner
field, select the schema or owner name for the source tables that you want to use to generate the Avro schema files.
The tables that match the selected schema or owner name are listed under
Tables
.
The following image shows an example list of tables that match a schema or owner name of INFA:
To filter the list of tables, in the
Filter
field, enter the first few letters of the source table names that you want to use for generating Avro schema files. For case-sensitive filtering, enclose the filter value in double quotation marks.
Only the tables that match the filter criteria are listed under
Tables
.
At any time, you can click
Refresh
to refresh the schemas for the source database and Kafka target.
Select the mapped tables to use for generating the Avro schema files:
To select all listed tables, click
Select All
.
To select tables individually, select the
Convert
check box in the table row.
When only one table is selected, you can click
Preview
to view a preview of the Avro schema text file that Data Replication will generate for the selected table.
The Data Replication Console generates schema files only for the mapped tables.
Under
Target
, verify that the
Database type
list displays
Apache Kafka
. You cannot edit this field.
In the
Message Format
field, select one of the following Avro schema formats to use for formatting messages:
avroFlatSchemaFormatV1
. Use the Avro flat schema format, which lists all Avro fields in one record.
avroNestedSchemaFormatV1
. Use the Avro nested schema format, which organizes each type of information in a separate record.
Optionally, in the
File Name Prefix
field, specify a prefix for the Avro schema file names.
Avro schema file prefixes can contain the digits 0-9, Latin letters A-Z and a-z, and the underscore (_) character.
To generate the Avro schema files, click
Save
. Then in the
Save
dialog box, save the generated schema files to a directory of your choice.
Data Replication creates a separate text file for each selected source table. The names for the generated text files use the following format: <
preifx
>_
table_name
.txt. You can use this file later with Kafka consumers that subscribe to the Kafka topics to which Data Replication writes messages.
Only mapped source columns are included in the generated schema files.