NewBie
NewBie

Reputation: 83

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**

Upvotes: 4

Views: 8974

Answers (2)

JITHIN_PATHROSE
JITHIN_PATHROSE

Reputation: 1396

I resolved this error by adding the property

spring:
   kafka:
      producer:
            value-serializer: io.confluent.kafka.serializers.protobuf.KafkaProtobufSerializer
      properties:
        auto:
          register:
            schemas: false

Upvotes: 1

NewBie
NewBie

Reputation: 83

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.

Upvotes: 3

Related Questions