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: src/reference/asciidoc/kafka.adoc
+146Lines changed: 146 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1917,6 +1917,152 @@ Note that `SimpleThreadScope` does not destroy beans that have a destruction int
1917
1917
IMPORTANT: By default, the application context's event multicaster invokes event listeners on the calling thread.
1918
1918
If you change the multicaster to use an async executor, thread cleanup is not effective.
1919
1919
1920
+
[[interceptors]]
1921
+
==== Wiring Spring Beans into Producer/Consumer Interceptors
1922
+
1923
+
Apache Kafka provides a mechanism to add interceptors to producers and consumers.
1924
+
These objects are managed by Kafka, not Spring, and so normal Spring dependency injection won't work for wiring in dependent Spring Beans.
1925
+
However, you can manually wire in those dependencies using the interceptor `config()` method.
1926
+
The following Spring Boot application shows how to do this by overriding boot's default factories to add some dependent bean into the configuration properties.
1927
+
1928
+
====
1929
+
[source, java]
1930
+
----
1931
+
@SpringBootApplication
1932
+
public class Application {
1933
+
1934
+
public static void main(String[] args) {
1935
+
SpringApplication.run(Application.class, args);
1936
+
}
1937
+
1938
+
@Bean
1939
+
public ConsumerFactory<?, ?> kafkaConsumerFactory(KafkaProperties properties, SomeBean someBean) {
0 commit comments