This is an automated email from the ASF dual-hosted git repository.
mmerli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new d6c06ff [doc] Add code samples for Protobuf and Avro schemas in java
documentation (#4670)
d6c06ff is described below
commit d6c06ffa909e1a179b28e5ac80d178efcbd7ba41
Author: vzhikserg <[email protected]>
AuthorDate: Thu Jul 4 17:07:34 2019 +0200
[doc] Add code samples for Protobuf and Avro schemas in java documentation
(#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.
---
site2/docs/client-libraries-java.md | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/site2/docs/client-libraries-java.md
b/site2/docs/client-libraries-java.md
index 16750c6..d4c7c1f 100644
--- a/site2/docs/client-libraries-java.md
+++ b/site2/docs/client-libraries-java.md
@@ -593,15 +593,31 @@ The following schema formats are currently available for
Java:
.topic("some-string-topic")
.create();
```
-* JSON schemas can be created for POJOs using the `JSONSchema` class. Here's
an example:
+
+* JSON schemas can be created for POJOs using `Schema.JSON`. Here's an example:
```java
- Schema<MyPojo> pojoSchema = JSONSchema.of(MyPojo.class);
- Producer<MyPojo> pojoProducer = client.newProducer(pojoSchema)
+ Producer<MyPojo> pojoProducer = client.newProducer(Schema.JSON(MyPojo.class))
.topic("some-pojo-topic")
.create();
```
+* Protobuf schemas can be generate using `Schema.PROTOBUF`. The following
example shows how to create the Protobuf schema and use it to instantiate a new
producer:
+
+ ```java
+ Producer<MyProtobuf> protobufProducer =
client.newProducer(Schema.PROTOBUF(MyProtobuf.class))
+ .topic("some-protobuf-topic")
+ .create();
+ ```
+
+* Avro schemas can be defined with the help of `Schema.AVRO`. The next code
snippet demonstrates the creation and usage of the Avro schema:
+
+ ```java
+ Producer<MyAvro> avroProducer = client.newProducer(Schema.AVRO(MyAvro.class))
+ .topic("some-avro-topic")
+ .create();
+ ```
+
## Authentication
Pulsar currently supports two authentication schemes:
[TLS](security-tls-authentication.md) and [Athenz](security-athenz.md). The
Pulsar Java client can be used with both.