Producer fails to use existing schema unless auto-registration creates a new version #6672
-
|
Hi, I have a query that I hope you could help me with.
.put(SerdeConfig.ARTIFACT_RESOLVER_STRATEGY, TopicIdStrategy.class.getName()) Could you explain why this happens? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Hi @EricWittmann, I've included the class below where I can reproduce the issue. In my test class, I registered the schema and then produced a message with auto-register set to false. In that case, it fails to find the schema. When I enable auto-register, it registers a new schema version. I also noticed that even a small change, such as adding a space or a comment, causes it to register a new schema version.
Test class - Proto Schema -
The schema that is registered by the test class is version 1 - Enabling auto register is creating a new version 2 schema -
Thanks in advance! |
Beta Was this translation helpful? Give feedback.
-
|
OK I have added a unit test for this, just to make sure I understood what happens. And more tests is always better. Here is the PR: I'll try to explain what's happening. When the serializer runs, what is MUST do is ensure that the schema it's using for serialization exists in the registry so that it can include a link to that schema in the message payload (or headers) - the link is used by consumers when deserializing. It can either register the schema itself, or it can verify that the schema exists already. If If
If you know the version you want to use, then configure the version number explicitly using If you just want to use the latest version, then configure If some or all of these options are not configured, then the schema resolver will try to find a version of an artifact that matches the content of the raw schema. For protobuf, the latter option often does not work because the raw schema will typically be a little bit different when extracted from the generated source files vs. the actual This is an area we can improve (protobuf content canonicalization). |
Beta Was this translation helpful? Give feedback.



OK I have added a unit test for this, just to make sure I understood what happens. And more tests is always better. Here is the PR:
#6680
I'll try to explain what's happening.
When the serializer runs, what is MUST do is ensure that the schema it's using for serialization exists in the registry so that it can include a link to that schema in the message payload (or headers) - the link is used by consumers when deserializing. It can either register the schema itself, or it can verify that the schema exists already.
If
autoRegisteris configured to betrue, then the serializer will extract the raw schema (e.g. the .proto file) from the generated sources and register it at the appropriate re…