2

Good day, I'm trying to set up ActiviMQ in a Spring Boot design to make the persistence of queues and topics in Oracle, however I'm not getting. I am making the following configuration to change the persistence method.

//imports
//...

@EnableAutoConfiguration(exclude = { ActiveMQAutoConfiguration.class })
@Configuration
public class RelatorioQueueConfig {

    public static final String NAME_METHOD_RUN_QUEUE = "receiverMessage";
    public static final String NAME_DESTINATION_QUEUE = "ActiveMQ.Advisory.TempTopic";
    private static final String MASTER_URL = "vm://localhost";

    @Autowired
    private ConnectionFactory connectionFactory;

    private MessageListenerAdapter requestMessageListener() {
        MessageListenerAdapter messageListener = new MessageListenerAdapter(new RelatorioServiceQueueReceiver());
        messageListener.setDefaultListenerMethod(RelatorioQueueConfig.NAME_METHOD_RUN_QUEUE);
        return messageListener;
    }

    @Bean
    public DefaultMessageListenerContainer requestMessageListenerContainer() {
        DefaultMessageListenerContainer requestMessageListenerContainer = new DefaultMessageListenerContainer();
        requestMessageListenerContainer.setConnectionFactory(this.connectionFactory);
        requestMessageListenerContainer.setMessageListener(this.requestMessageListener());
        requestMessageListenerContainer.setSessionTransacted(true);
        requestMessageListenerContainer.setDestinationName(RelatorioQueueConfig.NAME_DESTINATION_QUEUE);
        return requestMessageListenerContainer;
    }

    @Bean
    public ConnectionFactory connectionFactory() {
        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory(RelatorioQueueConfig.MASTER_URL);
        return connectionFactory;
    }

    @Bean
    public JmsTemplate jmsTemplate() {
        JmsTemplate jmsTemplate = new JmsTemplate(this.connectionFactory);
        jmsTemplate.setDefaultDestinationName(RelatorioQueueConfig.NAME_DESTINATION_QUEUE);
        return jmsTemplate;
    }


    //Persistence Oracle
    @Bean
    public PersistenceAdapter jdbcPersistenceAdapter() {
        final BasicDataSource basicDataSource = new BasicDataSource();
        basicDataSource.setDriverClassName("oracle.jdbc.OracleDriver");
        basicDataSource.setUrl("jdbc:oracle:thin:@172.23.20.100:1521:xe");
        basicDataSource.setUsername("sajadv5");
        basicDataSource.setPassword("adv123");
        basicDataSource.setMaxActive(200);
        basicDataSource.setPoolPreparedStatements(true);
        final JDBCPersistenceAdapter jdbcPersistenceAdapter = new JDBCPersistenceAdapter();
        jdbcPersistenceAdapter.setDataSource(basicDataSource);
        jdbcPersistenceAdapter.setDataDirectory("${activemq.base}/data");
        return jdbcPersistenceAdapter;
    }
}

When the application attempts to connect up in KahaDB out, what I do not want to have placed the persistence of Oracle.

André Justi
  • 71
  • 1
  • 2
  • 7
  • 1
    I can't answer your question (I've only configured ActiveMQ via XML, sorry), but just make sure you realize that the JDBC persistence adapters is slower than the KahaDB adapter (my impression is 2:1 or 3:1, but that's just from hearing about other people doing it, since I've never used the JDBC adapter). So if you care about performance and plan to route lots of messages through the broker, you might not want to use the JDBC adapter in the first place. – Tim Dec 24 '14 at 19:31
  • The easiest way is to use activemq.xml. Explained [here](https://stackoverflow.com/questions/30256761/activemq-configuration-with-spring-boot) – gotozero Jun 23 '17 at 10:22

0 Answers0