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
Fixes#475
Previously, containers were started in phase 0; thy should be
started in a late phase.
__cherry-pick to 2.0.x, 1.3.x__
(cherry picked from commit 39bf448)
# Conflicts:
# src/reference/asciidoc/kafka.adoc
Copy file name to clipboardExpand all lines: src/reference/asciidoc/kafka.adoc
+33Lines changed: 33 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -461,6 +461,14 @@ public interface Acknowledgment {
461
461
462
462
This gives the listener control over when offsets are committed.
463
463
464
+
[[container-auto-startup]]
465
+
====== Listener Container Auto Startup
466
+
467
+
The listener containers implement `SmartLifecycle` and `autoStartup` is `true` by default; the containers are started in a late phase (`Integer.MAX-VALUE - 100`).
468
+
Other components that implement `SmartLifecycle`, that handle data from listeners, should be started in an earlier phase.
469
+
The `- 100` leaves room for later phases to enable components to be auto-started after the containers.
470
+
471
+
464
472
[[kafka-listener-annotation]]
465
473
===== @KafkaListener Annotation
466
474
@@ -676,6 +684,31 @@ static class MultiListenerBean {
676
684
}
677
685
----
678
686
687
+
[[kafkalistener-lifecycle]]
688
+
===== @KafkaListener Lifecycle Management
689
+
690
+
The listener containers created for `@KafkaListener` annotations are not beans in the application context.
691
+
Instead, they are registered with an infrastructure bean of type `KafkaListenerEndpointRegistry`.
692
+
This bean manages the containers' lifecycles; it will auto-start any containers that have `autoStartup` set to `true`.
693
+
All containers created by all container factories must be in the same `phase` - see <<container-auto-startup>> for more information.
694
+
You can manage the lifecycle programmatically using the registry; starting/stopping the registry will start/stop all the registered containers.
695
+
Or, you can get a reference to an individual container using its `id` attribute; you can set `autoStartup` on the annotation, which will override the default setting configured into the container factory.
0 commit comments