You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
3
6
For non-primitive types, if the Schema is not explicitly specified when invoking send operations on the `{template-class}`, the Spring for Apache Pulsar framework will try to build a `Schema.JSON` from the type.
4
7
5
-
IMPORTANT: Complex Schema types that are currently supported are JSON, AVRO, PROTOBUF, and KEY_VALUE w/ INLINE encoding.
8
+
IMPORTANT: Complex Schema types that are currently supported are JSON, AVRO, PROTOBUF, AUTO_PRODUCE_BYTES, and KEY_VALUE w/ INLINE encoding.
6
9
7
10
=== Custom Schema Mapping
8
11
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.
@@ -11,3 +14,14 @@ This removes the need to specify the schema as the framework consults the resolv
11
14
include::custom-schema-mapping.adoc[]
12
15
13
16
With this configuration in place, there is no need to set specify the schema on send operations.
17
+
18
+
=== Producing with AUTO_SCHEMA
19
+
If there is no chance to know the type of schema of a Pulsar topic in advance, you can use an {apache-pulsar-docs}/schema-get-started/#auto_produce[AUTO_PRODUCE] schema to publish a raw JSON or Avro payload as a `byte[]` safely.
20
+
21
+
In this case, the producer validates whether the outbound bytes are compatible with the schema of the destination topic.
22
+
23
+
Simply specify a schema of `Schema.AUTO_PRODUCE_BYTES()` on your template send operations as shown in the example below:
24
+
25
+
include::{template-class}/template-snippet.adoc[]
26
+
27
+
NOTE: This is only supported with Avro and JSON schema types.
Copy file name to clipboardExpand all lines: spring-pulsar-reactive/src/test/java/org/springframework/pulsar/reactive/core/ReactivePulsarTemplateTests.java
+55-16Lines changed: 55 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2022-2023 the original author or authors.
2
+
* Copyright 2022-2024 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
0 commit comments