Currently, the entire RabbitStreamConfiguration is triggered by the listener type being equal to stream.
While this is correct for the container factory with bean name rabbitListenerContainerFactory, a user may wish to consume using one of the other containers as well as a stream. In this case, (s)he would declare a stream container factory with a different bean name.
However, this would need an auto configured Environment bean; otherwise (s)he would have to configure that too.
Consider making the Environment bean conditional on the presence of the spring-rabbit-stream jar, or simply, the Environment class being on the class path.
i.e. move the @ConditionalOnProperty from the class to the container factory.
Comment From: wilkinsona
Thanks for the suggestion, Gary.
move the
@ConditionalOnPropertyfrom the class to the container factory.
If we do that, in addition to auto-configuring the Environment bean, we'd also auto-configure a RabbitStreamTemplateConfigurer, and, potentially a RabbitStreamTemplate. Being able to have a RabbitStreamTemplate by setting spring.rabbitmq.stream.name while using a non-streaming rabbitListenerContainerFactory feels like it may be useful but I just wanted to double-check as you only mentioned the Environment above.
Comment From: garyrussell
Sorry, yes; I should have mentioned that configuring the stream template might also be useful, if it's on the CP.
I raised this because I am working with rabbit streams in spring-cloud-stream and had to set the listener type just to get an environment, even though I had no listeners.
Thanks.