Remove setSchema API from templates
For both PulsarTemplate and ReactivePulsarTemplate: * remove setSchema() * add schema param in simple API * add schema param in fluent API Update all tests and samples accordingly See #268
This commit is contained in:
@@ -1,19 +1,12 @@
|
||||
== Specifying Schema Information
|
||||
If you use Java primitive types, the framework auto-detects the schema for you, and you need not specify any schema types for publishing the data.
|
||||
However, if you use any complex types (such as `JSON`, `AVRO`, `PROTOBUF`, and others), you need to set the proper schema type on the `{template-class}` before invoking any send operations, as the following example shows for JSON:
|
||||
|
||||
====
|
||||
[source, java]
|
||||
----
|
||||
template.setSchema(Schema.JSON(Foo.class));
|
||||
----
|
||||
====
|
||||
However, if you use any complex types (such as `JSON`, `AVRO`, `PROTOBUF`, and others), you need to specify the proper schema when invoking send operations on the `{template-class}`.
|
||||
|
||||
IMPORTANT: Complex Schema types that are currently supported are JSON, AVRO, PROTOBUF, and KEY_VALUE w/ INLINE encoding.
|
||||
|
||||
=== Custom Schema Mapping
|
||||
As an alternative to specifying the schema on the `{template-class}` for complex types, the schema resolver can be configured with mappings for the types.
|
||||
This removes the need to set the schema on the template as the framework consults the resolver using the outgoing message type.
|
||||
As an alternative to specifying the schema when invoking send operations on the `{template-class}` for complex types, the schema resolver can be configured with mappings for the types.
|
||||
This removes the need to specify the schema as the framework consults the resolver using the outgoing message type.
|
||||
|
||||
The following example shows a schema resolver customizer that adds mappings for the `User` and `Address` complex objects using `AVRO` and `JSON` schemas, respectively:
|
||||
|
||||
@@ -29,11 +22,4 @@ public SchemaResolverCustomizer<DefaultSchemaResolver> schemaResolverCustomizer(
|
||||
}
|
||||
----
|
||||
====
|
||||
With this configuration in place, there is no need to set the schema on the template, for example:
|
||||
====
|
||||
[source, java]
|
||||
----
|
||||
template.send("user-topic", someUserObject);
|
||||
template.send("address-topic", someAddressObject);
|
||||
----
|
||||
====
|
||||
With this configuration in place, there is no need to set specify the schema on send operations.
|
||||
|
||||
Reference in New Issue
Block a user