-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[doc] Add code samples for Protobuf and Avro schemas in java documentation #4670
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
Conversation
site2/docs/client-libraries-java.md
Outdated
|
|
||
| ```java | ||
| Schema<MyProtobuf> protobufSchema = ProtobufSchema.of(MyProtobuf.class); | ||
| Producer<MyProtobuf> protobufProducer = client.newProducer(protobufSchema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The preferred form should be:
client.newProducer(Schema.PROTOBUF(MyProtobuf.class))There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I will change it. In my project the Schema.PROTOBUF form is used, but I wanted to keep it consistent with the sample for the JSON schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I see. Do you mind also changing the example for JSON?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I will update it
site2/docs/client-libraries-java.md
Outdated
|
|
||
| ```java | ||
| Schema<MyAvro> avroSchema = AvroSchema.of(MyAvro.class); | ||
| Producer<MyAvro> avroProducer = client.newProducer(avroSchema) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here:
client.newProducer(Schema.AVRO(MyProtobuf.class))…e preferred form.
merlimat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
…ation (apache#4670) * Add code samples for Protobuf and Avro schemas in java * Update the code snippets for JSON, Protobuf, and Avro schemas with the preferred form.
Motivation
We could not find Java examples which would include Avro and Protobuf schemas, but from the other documentation page it was clear that Pulsar supports them.
Modification
Two code snippets (one for Protobuf and the other one for Avro) were added to the Schema example chapter.