[jboss-user] [JBoss Messaging] - Re: Problems at Startup with MySQL 5 and XAConnection

felipeal do-not-reply at jboss.com
Mon Aug 28 22:11:33 EDT 2006


"timfox" wrote : 
  | As already mentioned, it's completely pointless using an XADatasource for the messaging database connection, since internally we suspend any current tx and create a new tx for the duration of the database operation. 
  | 

Forgive my ignorance (on the JBoss internals - I'm not really thaaat stupid when it comes to Java EE/XA/JTA,etc... :-), but how to achieve 2PC commit then? I mean, suppose I'm using a XADatasource for both my app's DB and my JBossMQ DB, add 100 messages in the queue, try to update the DB, get an exception and set the transaction for rollback. According to the 2PC/DTP land, the JBossMQ transaction should rollback as well. Of course, what must be rolled back is the transaction of the JBossMQ resource, not necessary its underlying database. But if the resource suspended my global-tx and started a new local-tx one, once I finished posting the 100 messages, that new tx would be committed (and ready to be consumed), right? Or am I missing something (I hope so...)?

"timfox" wrote : 
  | 1) Use the XAResource directly (this is a bit fiddly and I suggest you read the JTA spec first to ensure you know what you are doing)
  | 

That's too hardcore, and lacks all the Java EE fun - that code you showed looked more like the DTP/XA samples for C than Java/Java EE :-(

"timfox" wrote : 
  | Alternatively, if you are executing in a managed (read, JCA enabled) environment then you can use a UserTransaction, this is a whole lot easier.
  | 

Yes, that's what I'm doing; I'm even using Spring to start the UserTransaction for me...

"timfox" wrote : 
  | To do this, just start a user transaction, send your message and do your database update, commit and that should all happen in the same global tx.
  | 

That's what I did initially, and I thought JBoss would (by default) manage to enroll the 2 local transactions (DB and JMS) in a global/XA transaction. But once I deployed the application, the MDBs started to consume the messages before the global tx committed, so I realized something was not set correctly...

"timfox" wrote : 
  | You just need to make sure you are using the jms JCA resource adapter - this is the one normally available at java:/jmsXA, and are using a JCA managed data source for your database access.
  | 

To be honest, that was my first reaction - I've even found the java:/jmsXA reference somewhere (either on the wiki page on some XML file in the deploy dir), but after looking on some other places, I thought I would need to set a <xa-datasource> instead of <local-tx-datasource>...

"timfox" wrote : 
  | See the JCA wiki pages for more information.
  | 

Hmm, I think I got it now (http://wiki.jboss.org/wiki/Wiki.jsp?page=JBossJMSRA): I just need to change the JNDI name when getting the factory (somewhere in the Spring XML wasteland :-). I will try it tomorrow....

Thanks again for you help (and patience :-)

-- Felipe













View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3967977#3967977

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3967977



More information about the jboss-user mailing list