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
Copy file name to clipboardExpand all lines: spring-kafka-docs/src/main/asciidoc/kafka.adoc
+31
Original file line number
Diff line number
Diff line change
@@ -4762,6 +4762,8 @@ public interface KafkaHeaderMapper {
4762
4762
----
4763
4763
====
4764
4764
4765
+
The `SimpleKafkaHeaderMapper` maps raw headers as `byte[]`, with configuration options for conversion to `String` values.
4766
+
4765
4767
The `DefaultKafkaHeaderMapper` maps the key to the `MessageHeaders` header name and, in order to support rich header types for outbound messages, JSON conversion is performed.
4766
4768
A "`special`" header (with a key of `spring_json_header_types`) contains a JSON map of `<key>:<type>`.
4767
4769
This header is used on the inbound side to provide appropriate conversion of each header value to the original type.
@@ -4850,6 +4852,35 @@ public void testSpecificStringConvert() {
4850
4852
----
4851
4853
====
4852
4854
4855
+
Both header mappers map all inbound headers, by default.
4856
+
Starting with version 2.8.8, the patterns, can also applied to inbound mapping.
4857
+
To create a mapper for inbound mapping, use one of the static methods on the respective mapper:
4858
+
4859
+
====
4860
+
[source, java]
4861
+
----
4862
+
public static DefaultKafkaHeaderMapper forInboundOnlyWithMatchers(String... patterns) {
4863
+
}
4864
+
4865
+
public static DefaultKafkaHeaderMapper forInboundOnlyWithMatchers(ObjectMapper objectMapper, String... patterns) {
4866
+
}
4867
+
4868
+
public static SimpleKafkaHeaderMapper forInboundOnlyWithMatchers(String... patterns) {
This will exclude all headers beginning with `abc` and include all others.
4883
+
4853
4884
By default, the `DefaultKafkaHeaderMapper` is used in the `MessagingMessageConverter` and `BatchMessagingMessageConverter`, as long as Jackson is on the class path.
4854
4885
4855
4886
With the batch converter, the converted headers are available in the `KafkaHeaders.BATCH_CONVERTED_HEADERS` as a `List<Map<String, Object>>` where the map in a position of the list corresponds to the data position in the payload.
0 commit comments