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
Pulsar uses an internal Jackson `ObjectMapper` when de/serializing JSON messages.
6
-
If you instead want to provide your own object mapper instance, you can register a `SchemaResolverCustomizer` and set your mapper on the `DefaultSchemaResolver` as follows:
5
+
Pulsar uses an internal shaded Jackson `ObjectMapper` when de/serializing JSON messages.
6
+
If you instead want to provide your own Jackson 2 object mapper instance, you can register a `SchemaResolverCustomizer` and set your mapper on the `DefaultSchemaResolver` as follows:
IMPORTANT: The object mapper in the example above should be an instance of `com.fasterxml.jackson.databind.ObjectMapper`, **not** the shaded `org.apache.pulsar.shade.com.fasterxml.jackson.databind.ObjectMapper`.
20
+
19
21
This results in your object mapper being used to de/serialize all JSON messages that go through the schema resolution process (i.e. in cases where you do not pass a schema in directly when producing/consuming messages).
20
22
21
23
Under the hood, the resolver creates a special JSON schema which leverages the custom mapper and is used as the schema for all resolved JSON messages.
NOTE: A later version of the framework may instead provide a customizer that operates on the default mapper rather than requiring a separate instance.
51
+
52
+
[[jackson2vs3]]
53
+
== Jackson 2 / Jackson 3
54
+
In Spring Boot 4 the default version of {spring-boot-docs}/reference/features/json.html#features.json.jackson[Jackson is 3] and is auto-configured via the spring-boot-starter-json module.
55
+
However, Spring for Apache Pulsar expects a {spring-boot-docs}/reference/features/json.html#features.json.jackson2[Jackson 2] custom mapper.
56
+
57
+
If you are using Jackson 3 in your Spring Boot 4 application and want to use a custom mapper you will need to add Jackson 2 to the classpath.
58
+
Don't worry, Spring Boot 4 allows Jackson 2 and 3 to co-exist in an application.
59
+
60
+
NOTE: A later version of the framework may support using a Jackson 2 or Jackson 3 custom mapper.
Copy file name to clipboardExpand all lines: spring-pulsar-docs/src/main/antora/modules/ROOT/pages/reference/pulsar-header.adoc
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,7 @@ During inbound mapping, they are mapped as `String`.
44
44
By default, only `org.springframework.util.MimeType` and `org.springframework.http.MediaType` are mapped this way.
45
45
46
46
===== Custom ObjectMapper
47
-
The JSON mapper uses a reasonable configured Jasckson `ObjectMapper` to handle serialization of header values.
47
+
The JSON mapper uses a reasonable configured Jackson 2 `ObjectMapper` to handle serialization of header values.
48
48
However, to provide a custom object mapper one must simply provide an `ObjectMapper` bean with the name `pulsarHeaderObjectMapper`.
49
49
For example:
50
50
[source, java]
@@ -61,6 +61,10 @@ static class PulsarHeadersCustomObjectMapperTestConfig {
61
61
}
62
62
----
63
63
64
+
IMPORTANT: The object mapper in the example above should be an instance of `com.fasterxml.jackson.databind.ObjectMapper`, **not** the shaded `org.apache.pulsar.shade.com.fasterxml.jackson.databind.ObjectMapper`.
65
+
66
+
IMPORTANT: The xref:reference/custom-object-mapper.adoc#jackson2vs3[same limitations] regarding Jackson 2 vs. Jackson 3 apply here }
67
+
64
68
=== Inbound/Outbound Patterns
65
69
On the inbound side, by default, all Pulsar headers (message metadata plus user properties) are mapped to `MessageHeaders`.
66
70
On the outbound side, by default, all `MessageHeaders` are mapped, except `id`, `timestamp`, and the headers that represent the Pulsar message metadata (i.e. the headers that are prefixed with `pulsar_message_`).
0 commit comments