Search code examples
oracleactivemq-classicspring-jmsjmstemplate

Activemq jdbcPersistenceAdapter flushingmessages to database


I have a activemq jdbcPersistenceAdapter configured to use Oracle. The primary broker gets a lock, but when I send messages to the queue, I cannot see them in a database table. I do not want the the messages cached in any way, since they will not be consumed until there are no more producers (long story).

 <broker xmlns="http://activemq.apache.org/schema/core"  brokerName="primary" useJmx="true" useShutdownHook="false">

 <managementContext>
   <!-- use appserver provided context instead of creating one,
        for jboss use: -Djboss.platform.mbeanserver -->
   <managementContext createConnector="false"/>
 </managementContext>

<persistenceAdapter>
   <jdbcPersistenceAdapter dataSource="#oracle-ds" createTablesOnStartup="false" lockKeepAlivePeriod="30000"/>
 </persistenceAdapter>

<transportConnectors>
  <transportConnector uri="tcp://localhost:61616"/>
</transportConnectors>

 <!-- Spring JMS Producer Configuration -->
<bean id="jmsProducerTemplate" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="defaultDestination" ref="p3dPausedTransactionDestination"/>
    <property name="deliveryPersistent" value="true"/>
</bean>

<!-- Message Listener Container -->
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
    <property name="connectionFactory" ref="connectionFactory"/>
    <property name="destination" ref="p3dPausedTransactionDestination"/>
    <property name="messageListener" ref="transactionMessageConsumer" />
    <property name="sessionTransacted" value="true"/>
    <property name="autoStartup" value="true"/>
    <property name="sessionAcknowledgeModeName" value="AUTO_ACKNOWLEDGE"/>
</bean>

<!-- JMS Factory -->
<beans profile="local, test, dev, dev2, sit, uat, tt, prod">
    <bean id="connectionFactory" class="org.springframework.jms.connection.SingleConnectionFactory">
        <property name="targetConnectionFactory">
            <bean class="org.springframework.jndi.JndiObjectFactoryBean">
                <property name="jndiName" value="java:jboss/activemq/p3dConnectionFactory"/>
                <property name="lookupOnStartup" value="true"/>
            </bean>
        </property>
    </bean>
</beans>

Solution

  • Once I added the second broker, the messages started appearing in the database.