I have a Aries Blueprint file in my ServiceMix OSGi bundle, and I want to
achieve JTA/XA transactions using the default ServiceMix 4.4.0
("features:install transaction").

I am NOT using JPA, just raw JDBC calls.

How do I register my Xa Jms ConnectionFactory
(org.apache.activemq.ActiveMQXAConnectionFactory) and my Xa DataSource
(com.microsoft.sqlserver.jdbc.MySQLServerXADataSource) with the container's
transaction manager?


<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0";
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
    xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0";
    >

    
    <reference id="ariesTransactionManager"
interface="javax.transaction.TransactionManager" />

    
    <reference id="platformTransactionManager"
interface="org.springframework.transaction.PlatformTransactionManager" />
    
</blueprint>



I am expecting working code to take the following form:

--------  OPTION 1  --------


    <bean id="transactionServiceBean"
class="test.xa.service.TransactionServiceBean">
        <property name="transactionManager" ref="platformTransactionManager"
/>
        <property name="persistenceHelper" ref="persistenceHelperXa" />
    </bean>

public class TransactionServiceBean
{
    //...
    
    public void doTransactionCommit()
    {

        LOG.info( "doTransactionCommit() ->" );

        TransactionStatus transactionStatus;

        try
        {
            transactionStatus = transactionManager.getTransaction(
transactionDefinition );

        }
        catch( Exception e )
        {
            LOG.error( "Transaction failed:  ", e );
            return;
        }

        try
        {
            //  ...
            //  DO JMS AND JDBC STUFF HERE
            //  ...

            transactionManager.commit( transactionStatus );

        }
        catch( Exception e1 )
        {
            LOG.error( "Commit failed:  ", e1 );

            try
            {
                transactionManager.rollback( transactionStatus );
            }
            catch ( Exception e2 )
            {
                LOG.error( "Rollback failed:  ", e2 );
                throw new RuntimeException( e2 );
            }

            throw new RuntimeException( e1 );
        }

        LOG.info( "doTransactionCommit() <-" );


    }
    
    // ...
}

--------  OPTION 2  --------


    <bean id="transactionServiceBean"
class="test.xa.service.TransactionServiceBean">
        <tx:transaction method="do*" value="RequiresNew" />
    </bean>

public class TransactionServiceBean
{
    //...
        
    public void doTransactionCommit()
    {

        LOG.info( "doTransactionCommit() ->" );

        //  ...
        //  DO JMS AND JDBC STUFF HERE
        //  ...

        LOG.info( "doTransactionCommit() <-" );


    }
    
    // ...
}







--
View this message in context: 
http://servicemix.396122.n5.nabble.com/JTA-XA-transactions-using-the-default-ServiceMix-4-4-0-features-install-transaction-tp5434170p5434170.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to