My test flow like this:
jmsreceiver -> myinsert1 -> myinsert2 -> jmssender
it is synchronous and transacted.
Data will insert into two tables, the first table has no pk and the second
table has pk.

When first time data comes in, i find no commit has executed,  
log print "Resuming transaction for ID:xxxx ..." after all. 
Why Transaction not commit?
I don't know when and who begin, commit or rollback the transaction. Please
describe some details.

Data is not inserted until I add commit code in JcaConsumerProcessor. 
    public void process(MessageExchange exchange) throws Exception {
        Context context = (Context)
pendingMessages.remove(exchange.getExchangeId());
        Message message = (Message)
context.getProperty(Message.class.getName());
        Message response = null;
        Connection connection = null;
        try {
            if (exchange.getStatus() == ExchangeStatus.DONE) {
                //----------add
                TransactionManager tm = (TransactionManager)
endpoint.getServiceUnit().getComponent().getComponentContext().getTransactionManager();
                if(tm.getTransaction()!=null){
                        tm.commit();
                }
              //----------add end
                return;
            } else if ...
             

Same data insert next time will cause unique constraint violated
SqlException, and then rollback.
But rollback failed with exception:
10:23:39,686 WARN  pool-9-thread-5 - Transaction                    - Error
ending association for XAResource org.apache.gero
[EMAIL PROTECTED]; transaction will
roll back. XA error code: -7
org.apache.derby.client.am.XaException: XAER_RMFAIL :  
        at
org.apache.derby.client.net.NetXAResource.throwXAException(Unknown Source)
Why?

test with oracle, exception:
13:55:13,799 WARN  pool-5-thread-4 - Transaction                    - Error
ending association for XAResource org.apache.gero
[EMAIL PROTECTED]; transaction will
roll back. XA error code: -3
javax.transaction.xa.XAException
        at
oracle.jdbc.xa.OracleXAResource.allowGlobalTxnModeOnly(OracleXAResource.java:1102)

-- 
View this message in context: 
http://www.nabble.com/When-and-who-begin%2C-commit-or-rollback-the-transaction--tf2897278s12049.html#a8094642
Sent from the ServiceMix - Dev mailing list archive at Nabble.com.

Reply via email to