Class ContainerGroupSequencer
java.lang.Object
org.springframework.kafka.listener.ContainerGroupSequencer
- All Implemented Interfaces:
EventListener
,Aware
,ApplicationContextAware
,ApplicationListener<ListenerContainerIdleEvent>
,Lifecycle
,Phased
,SmartLifecycle
public class ContainerGroupSequencer
extends Object
implements ApplicationContextAware, ApplicationListener<ListenerContainerIdleEvent>, SmartLifecycle
Sequence the starting of container groups when all containers in the previous group are
idle.
- Since:
- 2.7.3
- Author:
- Gary Russell
-
Field Summary
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
ConstructorDescriptionContainerGroupSequencer
(ListenerContainerRegistry registry, long defaultIdleEventInterval, String... containerGroups) Set containers in each group to not auto start. -
Method Summary
Modifier and TypeMethodDescriptionint
getPhase()
void
boolean
boolean
void
void
setApplicationContext
(ApplicationContext applicationContext) void
setAutoStartup
(boolean autoStartup) Set to false to not automatically start.void
setPhase
(int phase) Set theSmartLifecycle.getPhase()
.void
setStopLastGroupWhenIdle
(boolean stopLastGroupWhenIdle) Set to true to stop the containers in the final group when they go idle.void
start()
void
stop()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.SmartLifecycle
stop
-
Constructor Details
-
ContainerGroupSequencer
public ContainerGroupSequencer(ListenerContainerRegistry registry, long defaultIdleEventInterval, String... containerGroups) Set containers in each group to not auto start. Start the containers in the first group. Start containers in group[n] when all containers in group[n-1] are idle; stop the containers in group[n-1].- Parameters:
registry
- the registry.defaultIdleEventInterval
- the idle event interval if not already set.containerGroups
- The list of container groups, in order.
-
-
Method Details
-
setApplicationContext
- Specified by:
setApplicationContext
in interfaceApplicationContextAware
- Throws:
BeansException
-
setStopLastGroupWhenIdle
public void setStopLastGroupWhenIdle(boolean stopLastGroupWhenIdle) Set to true to stop the containers in the final group when they go idle. By default, the containers in the final group remain running.- Parameters:
stopLastGroupWhenIdle
- true to stop containers in the final group.
-
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartup
in interfaceSmartLifecycle
-
setAutoStartup
public void setAutoStartup(boolean autoStartup) Set to false to not automatically start.- Parameters:
autoStartup
- false to not start;- Since:
- 2.7.6
-
getPhase
public int getPhase()- Specified by:
getPhase
in interfacePhased
- Specified by:
getPhase
in interfaceSmartLifecycle
-
setPhase
public void setPhase(int phase) Set theSmartLifecycle.getPhase()
.- Parameters:
phase
- the phase.- Since:
- 2.7.6
-
onApplicationEvent
- Specified by:
onApplicationEvent
in interfaceApplicationListener<ListenerContainerIdleEvent>
-
start
public void start() -
initialize
public void initialize() -
stop
public void stop() -
isRunning
public boolean isRunning()
-