'Exclude Autoconfiguration of Azure Service Bus without affecting Cosmos DB

We are using two Azure products in our prototype: Cosmos DB and Service Bus. For testing, we don't want to use Service Bus but ActiveMQ instead. The problem we are facing is that the autoconfigration of the Service Bus is not allowing activeMQ beans to be loaded, so we are trying to stop this auto configuration. To achieve this, we tried to excluded this configuration in the application config yaml:

spring:
  autoconfigure:         
      exclude:com.azure.spring.autoconfigure.jms.NonPremiumServiceBusJMSAutoConfiguration

This seems to block some common class with Cosmos DB client, so we are receiving this exception when running the application with the configuration above:

Unresolvable class definition for class [com.azure.spring.autoconfigure.cosmos.CosmosAutoConfiguration]

So I tried to include this class using the following configuration:

spring:
      autoconfigure:         
          exclude:com.azure.spring.autoconfigure.jms.NonPremiumServiceBusJMSAutoConfiguration
          include: com.azure.spring.autoconfigure.cosmos.CosmosAutoConfiguration

But this didn't work either. Is there a better way to achieve my goal or is there maybe something I did wrong here?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source