Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error while publishing message to kafka topic

I am new to Kafka. I have written a simple JAVA program to generate a message using avro schema. I have generated a specific record. The record is generated successfully. My schema is not yet registered with my local environment. It is currently registered with some other environment.

I am using the apache kafka producer library to publish the message to my local environment kafka topic. Can I publish the message to the local topic or the schema needs to be registered with the local schema registry as well.

Below are the producer properties -

        properties.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
        properties.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class);
        properties.put(KafkaAvroSerializerConfig.SCHEMA_REGISTRY_URL_CONFIG, "https://schema-registry.xxxx.service.dev:443");```

Error I am getting while publishing the message -
``` org.apache.kafka.common.errors.SerializationException: Error registering Avro schema: 
Caused by: io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException: User is denied operation Write on Subject: xxx.avro-value; error code: **40301**

like image 353
NewBie Avatar asked Oct 18 '25 12:10

NewBie


2 Answers

The issue was kafka producer by default tries to register the schema on topic. So, I added the below - properties.put(KafkaAvroSerializerConfig.AUTO_REGISTER_SCHEMAS, false); and it resolved the issue.

like image 130
NewBie Avatar answered Oct 20 '25 02:10

NewBie


I resolved this error by adding the property

spring:
   kafka:
      producer:
            value-serializer: io.confluent.kafka.serializers.protobuf.KafkaProtobufSerializer
      properties:
        auto:
          register:
            schemas: false
like image 26
JITHIN_PATHROSE Avatar answered Oct 20 '25 01:10

JITHIN_PATHROSE



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!