Hi camel riders,

I have a question. I’m trying to change my application from apacheMQ to Artemis.
I’m already using ApacheMQ and Springboot. 

At the moment I use this @Configuration. Do you know a better one?

@Configuration
public class ActiveMQ {

    @Value("${artemis.username}")
    String username = "admin";

    @Value("${artemis.password}")
    String password = "admin";

    private static final String QUEUE_BASE = "activemq:";

    public static final String QUEUE_IN = QUEUE_BASE + 
"magento.product.out.related";

    private static final String TOPIC_BASE = 
"activemq:topic:{{activemq.queue.prefix}}.";

    private static final String QUEUE_BASE_NO_TX = 
"activemqNoTx:{{activemq.queue.prefix}}.";

    private static final String TOPIC_BASE_NO_TX = 
"activemqNoTx:topic:{{activemq.queue.prefix}}.";

    @Bean(name = "pooledConnectionFactory")
    public CachingConnectionFactory 
createActiveMQConnectionPool(@Value("${spring.activemq.broker.url}") String 
brokerURL) {

        ActiveMQConnectionFactory connectionFactory = new 
ActiveMQJMSConnectionFactory(brokerURL, username, password);
        connectionFactory.setClientID(App.class.getPackage().getName());

        CachingConnectionFactory connectionPool = new 
CachingConnectionFactory(connectionFactory);
        connectionPool.setReconnectOnException(true);

        return connectionPool;
    }
    @Bean(name = "activemq")
    public ActiveMQComponent 
createActiveMQComponent(@Value("${spring.activemq.broker.url}") String 
brokerURL) {

        JmsConfiguration jmsConfiguration = new 
JmsConfiguration(createActiveMQConnectionPool(brokerURL));
        jmsConfiguration.setConcurrentConsumers(1);

        ActiveMQComponent activeMQComponent = new ActiveMQComponent();
        activeMQComponent.setConfiguration(jmsConfiguration);
        activeMQComponent.setTransacted(false);

        return activeMQComponent;
    }

}
Greetings

Tobias

Reply via email to