2
votes

I am creating a project with Spring-Boot that uses JMS over ActiveMq.

I set the following properties:

spring.activemq.broker-url=tcp://127.0.0.1:35000

spring.activemq.pooled=true

It is working fine, but I have no control over the properties of the connection pool. For example, I want to set the max number of connections in the connection pool.

Is there a way to set that?

And if I tried to configure ActiveMq myself in my Spring context xml file, Spring-boot is complaining about having problem with Autowiring 2 ConnectionFactory!

Is there a way to tell Spring-Boot not to autoconfigure any ActiveMq connection factory? (done by ActiveMQConnectionFactoryConfiguration in the spring-boot-autoconfigure library)

1

1 Answers

2
votes

All you need to do is provide a bean of type javax.jms.ConnectionFactory and instruct Spring Boot to not provide a default one.

The code would look like:

@Configuration
class YourActiveMQConnectionFactoryConfiguration {


    @Bean
    public ConnectionFactory jmsConnectionFactory() {
        return createFactory(); //do whatever you need to here
    }
}

In you main Application configuration class add the exclude property to @EnableAutoConfiguration.

@Configuration
@EnableAutoConfiguration(exclude=ActiveMQConnectionFactoryConfiguration.class)
//the rest of your annotations
public class AppConfig {

    //declare whatever other beans you need
}