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

Add:KafkaProducer validate message against schema before emitting . #7776

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

xonx4l
Copy link
Contributor

@xonx4l xonx4l commented Jan 10, 2024

Close: #7742

PR Details

This method first validates the message against the provided schema IDs. If the message does not conform to the specified schema, it throws an error. Then, it proceeds to serialize the message using the provided schema IDs and emits the message to the Kafka client. This way, the KafkaProducerService ensures that only valid messages are published to the Kafka topic, preventing potential issues for the consumers.

PR Checklist

  • [x ] npm test doesn't throw any error

Comment on lines +27 to +33
if (!schemaIds) {
throw new Error('Missing schema IDs');
}
const validationResult = await this.kafkaClient.validate(topic, message, schemaIds);
if (validationResult.errors) {
throw new Error('Message does not conform to the specified schema');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xonx4l sorry but I'm struggling to understand how the validation will work.
In addition validate doesn't exists in the kafkaClient object...

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

Successfully merging this pull request may close these issues.

None yet

2 participants