A longer response to @Lewis-munene comment:
After a group is finished and the next group starts, the first one is stopped (but not all the way, see my code comment on the stop()
invocation). If you want the first group to continue listening for new messages, add a 'watchdog' using Spring Events.
It's in Kotlin, but works in Java as well
@Component
class SubstationConsumerWatchdog(val applicationContext: ConfigurableApplicationContext) :
ApplicationListener<ContainerStoppedEvent> {
private val logger = KotlinLogging.logger {}
override fun onApplicationEvent(event: ContainerStoppedEvent) {
val firstGroup = applicationContext.getBean("g1.group", ContainerGroup::class.java)
if (firstGroup.allStopped()) {
logger.debug { "Restarting ContainerGroup 'g1'" }
firstGroup.stop() // to force the ContainerGroupSequencer.running boolean to false
firstGroup.start()
}
}
}