You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by li...@apache.org on 2021/08/30 02:46:17 UTC

[pulsar] branch master updated: [docs] add documentation for Schema.NATIVE_AVRO (#11801)

This is an automated email from the ASF dual-hosted git repository.

liuyu 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 8cc89df  [docs] add documentation for Schema.NATIVE_AVRO (#11801)
8cc89df is described below

commit 8cc89df5856f6d9d635f2861cd1be368378d710d
Author: Zhenhao Li <Zh...@users.noreply.github.com>
AuthorDate: Mon Aug 30 04:45:32 2021 +0200

    [docs] add documentation for Schema.NATIVE_AVRO (#11801)
    
    * first commit
    
    * update doc
---
 site2/docs/schema-understand.md | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/site2/docs/schema-understand.md b/site2/docs/schema-understand.md
index 507131c..12ba777 100644
--- a/site2/docs/schema-understand.md
+++ b/site2/docs/schema-understand.md
@@ -474,6 +474,25 @@ Message<GenericRecord> msg = consumer.receive() ;
 GenericRecord record = msg.getValue();
 ```
 
+### Native Avro Schema
+
+When migrating or ingesting event or message data from external systems (such as Kafka and Cassandra), the events are often already serialized in Avro format. The applications producing the data typically have validated the data against their schemas (including compatibility checks) and stored them in a database or a dedicated service (such as a schema registry). The schema of each serialized data record is usually retrievable by some metadata attached to that record. In such cases, a Pu [...]
+
+Hence, we provide `Schema.NATIVE_AVRO` to wrap a native Avro schema of type `org.apache.avro.Schema`. The result is a schema instance of Pulsar that accepts a serialized Avro payload without validating it against the wrapped Avro schema.
+
+**Example**
+
+```java
+org.apache.avro.Schema nativeAvroSchema = … ;
+
+Producer<byte[]> producer = pulsarClient.newProducer().topic("ingress").create();
+
+byte[] content = … ;
+
+producer.newMessage(Schema.NATIVE_AVRO(nativeAvroSchema)).value(content).send();
+
+```
+
 ## Schema version
 
 Each `SchemaInfo` stored with a topic has a version. Schema version manages schema changes happening within a topic.