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
+29-1Lines changed: 29 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -5578,7 +5578,7 @@ Key exceptions are only caused by `DeserializationException` s so there is no `D
5578
5578
There are two mechanisms to add more headers.
5579
5579
5580
5580
1. Subclass the recoverer and override `createProducerRecord()` - call `super.createProducerRecord()` and add more headers.
5581
-
2. Provide a `BiFunction` to receive the consumer record and exception, returning a `Headers` object; headers from there will be copied to the final producer record.
5581
+
2. Provide a `BiFunction` to receive the consumer record and exception, returning a `Headers` object; headers from there will be copied to the final producer record; also see <<dlpr-headers>>.
5582
5582
Use `setHeadersFunction()` to set the `BiFunction`.
5583
5583
5584
5584
The second is simpler to implement but the first has more information available, including the already assembled standard headers.
@@ -5673,6 +5673,34 @@ The reason for the two properties is because, while you might want to retain onl
5673
5673
5674
5674
`appendOriginalHeaders` is applied to all headers named `*ORIGINAL*` while `stripPreviousExceptionHeaders` is applied to all headers named `*EXCEPTION*`.
5675
5675
5676
+
Starting with version 2.8.4, you now can control which of the standard headers will be added to the output record.
5677
+
See the `enum HeadersToAdd` for the generic names of the (currently) 10 standard headers that are added by default (these are not the actual header names, just an abstraction; the actual header names are set up by the `getHeaderNames()` method which subclasses can override.
5678
+
5679
+
To exclude headers, use the `excludeHeaders()` method; for example, to suppress adding the exception stack trace in a header, use:
5680
+
5681
+
====
5682
+
[source, java]
5683
+
----
5684
+
DeadLetterPublishingRecoverer recoverer = new DeadLetterPublishingRecoverer(template);
In addition, you can completely customize the addition of exception headers by adding an `ExceptionHeadersCreator`; this also disables all standard exception headers.
5690
+
5691
+
====
5692
+
[source, java]
5693
+
----
5694
+
DeadLetterPublishingRecoverer recoverer = new DeadLetterPublishingRecoverer(template);
Starting with version 2.8.4, if you wish to add custom headers (in addition to the retry information headers added by the factory, you can add a `headersFunction` to the factory - `factory.setHeadersFunction((rec, ex) -> { ... })`
0 commit comments