Skip to content

Could not add AVRO schema using producer client #9602

@rvashishth

Description

@rvashishth

Describe the bug
Unable to add AVRO schema on a topic using producer client.

To Reproduce
Steps to reproduce the behavior:

  1. create a topic
  2. produce a message with json schema
Producer<User> producer = client.newProducer(Schema.JSON(User.class)).topic(Commons.TOPIC).create();
      User user = new User("rahul",31);
      MessageId msgId = producer.send(user);
  1. get schema api - return json schema type
{
    "getSchemaResponses": [
        {
            "version": 0,
            "type": "JSON",
            "timestamp": 0,
            "data": "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"com.optum.link.pulsar\",\"fields\":[{\"name\":\"name\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"age\",\"type\":\"int\"}]}",
            "properties": {
                "__jsr310ConversionEnabled": "false",
                "__alwaysAllowNull": "true"
            }
        }
    ]
}
  1. produce 2nd message with avro schema
Producer<User> producer = client.newProducer(Schema.AVRO(User.class)).topic(Commons.TOPIC).create();
      User user = new User("josh",31);
      MessageId msgId = producer.send(user);
  1. get schema api - returns only previously created json schema object. it did not include AVRO schema
{
    "getSchemaResponses": [
        {
            "version": 0,
            "type": "JSON",
            "timestamp": 0,
            "data": "{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"com.optum.link.pulsar\",\"fields\":[{\"name\":\"name\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"age\",\"type\":\"int\"}]}",
            "properties": {
                "__jsr310ConversionEnabled": "false",
                "__alwaysAllowNull": "true"
            }
        }
    ]
}

Expected behavior
Avro schema should be added pulsar schema registry, or if this is not feasible then producer client should throw error

Screenshots
NA

Desktop (please complete the following information):

  • OS: iOS
  • Pulsar: 2.7.0
  • Pulsar Client: 2.7.0

Additional context
I could successfully produce/consume messages using json schema.

Metadata

Metadata

Assignees

Labels

deprecated/questionQuestions should happened in GitHub Discussions

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions