使用Oracle配置Spring + ActiveMQ

时间:2014-12-24 13:47:25

标签: spring oracle activemq

美好的一天, 我正在尝试在Spring Boot设计中设置ActiviMQ,以便在Oracle中保持队列和主题的持久性,但是我没有得到。 我正在进行以下配置以更改持久性方法。

//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;
    }
}

当应用程序尝试连接KahaDB时,我不想放置Oracle的持久性。

0 个答案:

没有答案