AvroSchemaRegistry controller service
Avro schema
Avro schema is created in JSON document format, which is a lightweight, text-based data interchange format. It is created in one of the following ways:
- JSON string
- JSON object
- JSON Array
Primitive data types of Avro
Data type |
Description |
Null | Null is a type having no value. |
int | 32-bit signed integer. |
long | 64-bit signed integer. |
float | Single precision (32-bit) IEEE 754 floating-point number. |
double | Double precision (64-bit) IEEE 754 floating-point number. |
bytes | Sequence of 8-bit unsigned bytes. |
string | Unicode character sequence. |
Complex data types of Avro
Along with primitive data types, Avro provides six complex data types such as Records, Enum, Arrays, Maps, Unions, and Fixed.
For example, When you convert the response from one format into another, specify the Avro schema in AvroSchemaRegistry controller service to get the output response in which type you needed.
Consider you have employee details in Avro format response, it can be converted into JSON by using the following schema.
{
"type" : "record",
"namespace" : "EmployeeDetails",
"name" : "Employee",
"fields" : [
{ "name" : "Name" , "type" : "string" },
{ "name" : "Age" , "type" : "int" }
]
}
In the previous example:
- Type: Describes document types, in this case a "record" is a document type.
- Namespace: Describes the name of the namespace in which the object resides.
- Name: Describes the schema name.
- Fields: This is an attribute array which contains the attributes for your response.
- In this case, name and type are the name and data type of the corresponding fields.
For the following scenarios, AvroSchemaRegistry controller service is needed:
- For converting Avro format response into JSON format.
- For converting CSV format response into JSON format.
Possible controller services in which AvroSchemaRegistry can be used:
- AvroReader
- AvroRecordSetWriter
- CSVReader
- CSVRecordSetWriter
- JsonPathReader
- JsonRecordSetWriter
- JsonTreeReader
- SQLRecordSetWriter
Possible processors in which AvroSchemaRegistry can be used:
Configure AvroSchemaRegistry controller service
- In controller service dialog, create a new controller service using Add icon.
- Search and add AvroSchemaRegistry controller service.
- Click configure icon to add schema to the output response.
- Add the dynamic property and required schema as value for this property. Refer to the following screenshot.
- After configuring the previous steps, enable the controller service. Refer to the following screenshot.