spring-projects/spring-data-redis

Allow overriding phase in RedisMessageListenerContainer

Closed this issue · 3 comments

Title: Allow overriding phase in RedisMessageListenerContainer

Description:
Currently, RedisMessageListenerContainer uses the default SmartLifecycle phase of Integer.MAX_VALUE.
This makes it difficult to control startup/shutdown ordering relative to other SmartLifecycle beans in the application.

In some scenarios, developers may want to ensure that certain beans start after the Redis listener container is fully initialized, or conversely, that the container waits until other infrastructure is ready before starting. Since the phase is not configurable, fine-grained lifecycle control is not possible.

Proposal:
Introduce the ability to override the phase of RedisMessageListenerContainer, for example by:

  • Exposing a setPhase(int phase) method

Use case:

  • Ensuring custom initialization logic (that depends on the container being ready) runs after the container is started.
  • Aligning the container’s lifecycle with other messaging or connection beans that also implement SmartLifecycle.

Hi @mp911de
I’d like to contribute this issue
Is it okay if I take this issue and prepare an implementation?

Sure feel free to submit a pull request.