Cannot find DB row after transaction (intermittent).

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Cannot find DB row after transaction (intermittent).

CJameson
Hi

When using:

Bitronix 2.0.1
Spring 3.1.1
Hibernate 3.5.6
ActiveMQ 5.5.1
Oracle

In a @Transaction which does:

1. entityManager.persist(myObj);
2. entityManager.flush()
3. [JMSSend]

When later doing an entityManager.find(), 99.9% of the time the entity is returned successfully. However, other times this returns null.

Does the configuration look correct? (note: using LrcXAConnectionFactory for JMS) ...

datasource-context.xml:

<bean id="dataSource" class="bitronix.tm.resource.jdbc.PoolingDataSource" init-method="init" destroy-method="close">
        <property name="className" value="oracle.jdbc.xa.client.OracleXADataSource" />
        <property name="uniqueName" value="oracle" />
        <property name="maxPoolSize" value="5" />
        <property name="allowLocalTransactions" value="true"></property>
        <property name="driverProperties">
                <props>
                        <prop key="user">${user}</prop>
                        <prop key="password">${password}</prop>
                        <prop key="URL">${url}</prop>
                </props>
        </property>
</bean>

persistence.xml:

<persistence-unit name="com.xyz" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>org.drools.persistence.info.SessionInfo</class>
        <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
        <class>org.drools.persistence.info.WorkItemInfo</class>
        <properties>
                <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect" />
                <property name="allowLocalTransactions" value="false" />
                <property name="hibernate.hbm2ddl.auto" value="validate" />
                <property name="hibernate.format_sql" value="false" />
        </properties>
</persistence-unit>

jms-context.xml:

<bean id="xaJmsConnectionFactory" class="bitronix.tm.resource.jms.PoolingConnectionFactory" init-method="init"
        destroy-method="close" depends-on="sslKeystoreTransportFactoryInitializer">
        <property name="className" value="bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory" />
        <property name="uniqueName" value="activemq" />
        <property name="minPoolSize" value="1" />
        <property name="maxPoolSize" value="10" />
        <property name="acquisitionTimeout" value="300" />
        <property name="allowLocalTransactions" value="false" />
        <property name="driverProperties">
                <props>
                        <prop key="connectionFactoryClassName">org.apache.activemq.ActiveMQConnectionFactory</prop>
                        <prop key="properties.brokerURL">${jms.brokerUrl}?jms.redeliveryPolicy.maximumRedeliveries=-1&jms.redeliveryPolicy.initialRedeliveryDelay=0&jms.redeliveryPolicy.redeliveryDelay=10000
                        </prop>
                </props>
        </property>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="xaJmsConnectionFactory" />
</bean>
Reply | Threaded
Open this post in threaded view
|

Re: Cannot find DB row after transaction (intermittent).

Ludovic Orban-2
Hi,

From what I can tell everything looks good, especially since it all works fine 99.9% of the time as you say. There are many factors which could explain this problem, and it may or may not be related to BTM itself.

I wonder why you need to call flush() on your entity manager, how you configured the latter, how you are demarcating your transactions (using Spring annotations / XML config? EJBs? using the JTA API directly?) and why you allowed local transactions on your datasource.

I'd be happy to help you figure out the cause of this problem but I would need more details to do so. For instance, I would need to know precisely where you are beginning and committing your transactions.

--
Ludovic

On Wed, Mar 6, 2013 at 10:32 AM, mdoubleu <[hidden email]> wrote:
Hi

When using:

Bitronix 2.0.1
Spring 3.1.1
Hibernate 3.5.6
ActiveMQ 5.5.1
Oracle

In a @Transaction which does:

1. entityManager.persist(myObj);
2. entityManager.flush()
3. [JMSSend]

When later doing an entityManager.find(), 99.9% of the time the entity is
returned successfully. However, other times this returns null.

Does the configuration look correct? (note: using LrcXAConnectionFactory for
JMS) ...

*datasource-context.xml:*

<bean id="dataSource" class="bitronix.tm.resource.jdbc.PoolingDataSource"
init-method="init" destroy-method="close">
        <property name="className" value="oracle.jdbc.xa.client.OracleXADataSource"
/>
        <property name="uniqueName" value="oracle" />
        <property name="maxPoolSize" value="5" />
        <property name="allowLocalTransactions" value="true"></property>
        <property name="driverProperties">
                <props>
                        <prop key="user">${user}</prop>
                        <prop key="password">${password}</prop>
                        <prop key="URL">${url}</prop>
                </props>
        </property>
</bean>

*persistence.xml:*

<persistence-unit name="com.xyz" transaction-type="JTA">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <class>org.drools.persistence.info.SessionInfo</class>
        <class>org.jbpm.persistence.processinstance.ProcessInstanceInfo</class>
        <class>org.drools.persistence.info.WorkItemInfo</class>
        <properties>
                <property name="hibernate.dialect"
value="org.hibernate.dialect.Oracle10gDialect" />
                <property name="allowLocalTransactions" value="false" />
                <property name="hibernate.hbm2ddl.auto" value="validate" />
                <property name="hibernate.format_sql" value="false" />
        </properties>
</persistence-unit>

*jms-context.xml:*

<bean id="xaJmsConnectionFactory"
class="bitronix.tm.resource.jms.PoolingConnectionFactory" init-method="init"
        destroy-method="close" depends-on="sslKeystoreTransportFactoryInitializer">
        <property name="className"
value="bitronix.tm.resource.jms.lrc.LrcXAConnectionFactory" />
        <property name="uniqueName" value="activemq" />
        <property name="minPoolSize" value="1" />
        <property name="maxPoolSize" value="10" />
        <property name="acquisitionTimeout" value="300" />
        <property name="allowLocalTransactions" value="false" />
        <property name="driverProperties">
                <props>
                        <prop
key="connectionFactoryClassName">org.apache.activemq.ActiveMQConnectionFactory</prop>
                        <prop
key="properties.brokerURL">${jms.brokerUrl}?jms.redeliveryPolicy.maximumRedeliveries=-1&amp;jms.redeliveryPolicy.initialRedeliveryDelay=0&amp;jms.redeliveryPolicy.redeliveryDelay=10000
                        </prop>
                </props>
        </property>
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
        <property name="connectionFactory" ref="xaJmsConnectionFactory" />
</bean>



--
View this message in context: http://bitronix-transaction-manager.10986.n7.nabble.com/Cannot-find-DB-row-after-transaction-intermittent-tp1444.html
Sent from the Bitronix Transaction Manager mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



Reply | Threaded
Open this post in threaded view
|

Re: Cannot find DB row after transaction (intermittent).

CJameson
Hi

Thanks for taking the time to answer.

In the end this was resolved by using ActiveMQ XA instead of LRC, since LRC was allowing a separate transaction to consume the message while the 2PC transaction was in mid-flight. It now works 100% of the time. I'm aware of the Suspend/Resume limitation with ActiveMQ XA, but this isn't being used at present.

Transactions are demarcated using Spring annotations.