ibm-messaging / mq-jms-spring

Components to assist MQ JMS integration with Spring frameworks
Apache License 2.0
190 stars 102 forks source link

Add property to disable auto-configuration #86

Closed ohubaut closed 1 year ago

ohubaut commented 2 years ago

There is currently no way to disable the starter once it is on the classpath. During the development lifecycle, to avoid connecting to a real MQ broker, we often rely on an embedded broker (typically, ActiveMQ), which allows for quick Unit Tests / Integration Tests with low footprint

I know that there is the Docker image of the MQ broker, but that is an extra bit of software to launch prior to running the test, and that is not run by default, which is problematic for CI infrastructure. Having a TestContainer could help, but I think the footprint would still be heavier.

On top of that, that could also be used to package application that provide connectors to several different JMS implementation.

Affected versions

All

Java version

All

Proposed change

Adding an @ConditinalOnProperty annotation on the MQAutoConfiguration class with a property that would disable it completely.

ibmmqmet commented 2 years ago

I could think about putting a property in there with the default value (if not set) to keep the class enabled. Disabling configuration would need to be an explicit action.

I'm not certain how well it would actually work - how guaranteed the ordering is for different implementation instantiations if you have multiple JMS providers on the classpath. And that might make development tasks more complex, not less.

thuri commented 2 years ago

@ohubaut Have you tried adding @EnableAutoConfiguration(exclude = com.ibm.mq.spring.boot.MQAutoConfiguration.class) to the test class or set spring.autoconfigure.exclude property to com.ibm.mq.spring.boot.MQAutoConfiguration in the src/test/resources/application.(yml|properties) ?

ohubaut commented 2 years ago

Hi @thuri,

Thanks for the suggestion. That is indeed what we ended up doing in our test classes.

In the meantime, we are also building our own helm chart based on the icr.io/ibm-messaging/mq docker image, for local deployment. We considered using the official helm chart provided by IBM but it does not allow for automatic creation of queues at deployment time, and since we want to have truly ephemeral environment, this image offer more flexibility.

ibmmqmet commented 1 year ago

ibm.mq.autoConfigure made available in v2.7.5