Skip to content

Conversation

@vzhikserg
Copy link
Contributor

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.


```java
Schema<MyProtobuf> protobufSchema = ProtobufSchema.of(MyProtobuf.class);
Producer<MyProtobuf> protobufProducer = client.newProducer(protobufSchema)
Copy link
Contributor

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))

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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


```java
Schema<MyAvro> avroSchema = AvroSchema.of(MyAvro.class);
Producer<MyAvro> avroProducer = client.newProducer(avroSchema)
Copy link
Contributor

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))

@merlimat merlimat added the doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. label Jul 3, 2019
@merlimat merlimat added this to the 2.5.0 milestone Jul 3, 2019
Copy link
Contributor

@merlimat merlimat left a comment

Choose a reason for hiding this comment

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

👍

@merlimat merlimat merged commit d6c06ff into apache:master Jul 4, 2019
@vzhikserg vzhikserg deleted the add-doc-for-schemas-in-java branch July 5, 2019 09:49
easyfan pushed a commit to easyfan/pulsar that referenced this pull request Jul 26, 2019
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Your PR contains doc changes, no matter whether the changes are in markdown or code files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants