Produce Kafka message using array in Avro Schema

60 views Asked by At

I created avro schema using an array of records

   [
    {
        "type": "record",
        "name": "BbbAvro",
        "fields": [
            {
                "name": "ddd",
                "type": "string"
            }
        ]
    },
    {
        "type": "record",
        "name": "AaaAvro",
        "fields": [
            {
                "name": "ccc",
                "type": "string"
            },
            {
                "name": "xxx",
                "type": "string"
            }
        ]
    },
    {
        "type": "record",
        "name": "MainAvro",
        "fields": [
            {
                "name": "bbb",
                "type": "BbbAvro"
            },
            {
                "name": "aaa",
                "type": "AaaAvro"
            }
        ]
    }
]

If I use Java code to produce the message (create an object and send) it works ok, but if I try to send kafka message manually to topic it doesnt work.

 {
    "aaa": {
        "ccc": "ccc",
        "xxx": "xxx"
    },
    "bbb": {
        "ddd": "ddd",
    }
}

How can I produce a message manually?

1

There are 1 answers

0
Prashant Gupta On

Convert the JSON message into a single line using any online editor and then try to send it manually, try this one https://www.text-utils.com/json-formatter/