Class ContainerGroupSequencer
- java.lang.Object
-
- org.springframework.kafka.listener.ContainerGroupSequencer
-
- All Implemented Interfaces:
java.util.EventListener
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
,org.springframework.context.ApplicationListener<ListenerContainerIdleEvent>
,org.springframework.context.Lifecycle
,org.springframework.context.Phased
,org.springframework.context.SmartLifecycle
public class ContainerGroupSequencer extends java.lang.Object implements org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<ListenerContainerIdleEvent>, org.springframework.context.SmartLifecycle
Sequence the starting of container groups when all containers in the previous group are idle.- Since:
- 2.7.3
-
-
Constructor Summary
Constructors Constructor Description ContainerGroupSequencer(ListenerContainerRegistry registry, long defaultIdleEventInterval, java.lang.String... containerGroups)
Set containers in each group to not auto start.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getPhase()
void
initialize()
boolean
isAutoStartup()
boolean
isRunning()
void
onApplicationEvent(ListenerContainerIdleEvent event)
void
setApplicationContext(org.springframework.context.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()
-
-
-
Constructor Detail
-
ContainerGroupSequencer
public ContainerGroupSequencer(ListenerContainerRegistry registry, long defaultIdleEventInterval, java.lang.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 Detail
-
setApplicationContext
public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
- Specified by:
setApplicationContext
in interfaceorg.springframework.context.ApplicationContextAware
- Throws:
org.springframework.beans.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 interfaceorg.springframework.context.SmartLifecycle
-
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 interfaceorg.springframework.context.Phased
- Specified by:
getPhase
in interfaceorg.springframework.context.SmartLifecycle
-
setPhase
public void setPhase(int phase)
Set theSmartLifecycle.getPhase()
.- Parameters:
phase
- the phase.- Since:
- 2.7.6
-
onApplicationEvent
public void onApplicationEvent(ListenerContainerIdleEvent event)
- Specified by:
onApplicationEvent
in interfaceorg.springframework.context.ApplicationListener<ListenerContainerIdleEvent>
-
start
public void start()
- Specified by:
start
in interfaceorg.springframework.context.Lifecycle
-
initialize
public void initialize()
-
stop
public void stop()
- Specified by:
stop
in interfaceorg.springframework.context.Lifecycle
-
isRunning
public boolean isRunning()
- Specified by:
isRunning
in interfaceorg.springframework.context.Lifecycle
-
-