Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Producing messages doesn't encode magic byte and schema id #93

Open
tzachshabtay opened this issue May 27, 2020 · 1 comment
Open

Producing messages doesn't encode magic byte and schema id #93

tzachshabtay opened this issue May 27, 2020 · 1 comment

Comments

@tzachshabtay
Copy link

Using [email protected], I have a topic called test, I'm using the RecordNameStrategy and have registered a subject test in the schema registry.

Producing my message:

class test { }

const producer = await kafkaAvro.getProducer()
const data = new test()
data.long_field = 10
producer.produce('test', -1, data, 'key');

Produces the message but without the encoded schema.
The problem seem to stem from the fact that kafka-avro seems opinionated about the subject name (and I didn't see it mentioned in the docs). It seems to expect all topics to either end with -value or -key:

const parts = schemaTopic.split('-');

If it doesn't match that, it falls back and puts it in the keys schemas and doesn't put it in the values schemas:

if (schemaObj.schemaType.toLowerCase() === 'value') {

And then when it tries to produce the message it won't find the schema as it's not in the values schemas dictionary and fail to encode it.

@ricardohbin
Copy link
Collaborator

This is the standard of schema-registry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants