Atomikos Forum

Transaction Manager for postgreSQL & XADisk (for file systems)

Hello,
has anybody experience using Atomikos in conjunction with XADisk (transaction management for a file system) ?

My goal is to have transactional integrity for the DB and the file system.

My scenario:
- self written J2SE server based on Netbeans
- postgresSQL database
- file system managed by XADisk

For the DB I could use Atomikos JDBC and the User Transaction (chapter 4.1 of the Atomikos TransactionsEssential Guide) but for XADisk I would need the JTA Transaction Manager (chapter 4.2).

Is it possible to mix both approaches (I don't want to lose the advantages of Atomikos JDBC)?
If so, how?

Thanks a lot in advance

timekeeper
time keeper Send private email
Saturday, August 06, 2011
 
 
Hello,

XAResource is a standard point of integration between Transaction-Manager and resources involved, and I am sure Atomikos would treat all such XAResources independent of where do they come from. So, you should be able to do something like this:

_____________________________________________________

Transaction txn = tm.getTransaction();

com.atomikos.jdbc.SimpleDataSourceBean ds = new com.atomikos.jdbc.SimpleDataSourceBean();

XAConnection xAConnection = ds.getXaDataSource().getXAConnection();
XAResource xar1 = xAConnection.getXAResource();
txn.enlistResource(xar1);

XAResource xar2 = //xar from XADisk
txn.enlistResource(xar2);

_____________________________________________________

Please give it a try and see if works for you. I didn't have a chance to test the above, but please let me know if you face any issues.

Thanks,
Nitin
Nitin Verma Send private email
Monday, August 08, 2011
 
 
Hello Nitrin,
I'm using Version 3.7 of Atomikos and the documentation says:

Deprecated:
As of release 3.3, the com.atomikos.jdbc.AtomikosDataSourceBean should be used instead.

Is this correct?

timekeeper
time keeper Send private email
Tuesday, August 09, 2011
 
 
Hello,

I too have come across this in the documentation. Though I am not an Atomikos expert, it is generally a good practice to use the latest API instead of the deprecated one. In this case, you can simple use AtomikosDataSourceBean and the steps I wrote to retrieve the XAResource would remain the same.

Thanks,
Nitin
Nitin Verma Send private email
Wednesday, August 10, 2011
 
 
....<continued>  Forgot to mention that you may want to confirm the steps I wrote with some testing. It would be great to know if you could integrate the two resources: DB and XADisk.
Nitin Verma Send private email
Wednesday, August 10, 2011
 
 
Hello Nitrin,
I have a problem with my startup code:

    UserTransactionServiceFactory utsFactory = new UserTransactionServiceFactory();
    uts = utsFactory.getUserTransactionService(tsProperties);

    dbDataSource = dbConfig.createDataSource();
    LOG.info("registering JDBC-Resource");
    JdbcTransactionalResource jdbcResource = new JdbcTransactionalResource(
            "de.hermannmatthes.workbench.dbDataSource", dbDataSource);
    uts.registerResource(jdbcResource);

    xaFileSystem = XAFileSystemProxy.bootNativeXAFileSystem(createXaConfig());
    xaFileSystem.waitForBootup(10000L);
    LOG.info("Booting completed for the XADisk instance.");
    LOG.info("registering XADisk-Resource");
    ManagedConnectionFactory mcf = new XADiskManagedConnectionFactory();
    ((XADiskManagedConnectionFactory) mcf).setInstanceId(fsConfig.getFsInstanceName());
    JcaTransactionalResource xaResource = new JcaTransactionalResource(fsConfig.getFsInstanceName(), mcf);
    uts.registerResource(xaResource);

    LOG.info("Atomikos startup successfully completed!");

The code runs without visible errors but if I afterwards try to use a XASession (which I obtain with xaFileSystem.createSessionForXATransaction()), I get the following error:
NoTransactionAssociatedException: The method that was called can only be called with a transaction associated, but there is no such transaction present.

In the debugger I see that the XASession (it's a NativeXASession) the components sessionOfXATransaction and sessionOfLocalTransaction are null. It seems that my startup code is wrong because in my mind sessionOfXATransaction should be set.

Is the approach of using XADiskManagedConnectionFactory wrong?

Can you please help?
Any hint is welcome.

Hermann
time keeper Send private email
Friday, August 12, 2011
 
 
Hurra, it works. And it's relatively simple. For JDBC I use the AtomikosDataSourceBean and for XADisk I do enlist/delist for myself.

If someone wants me to provide the code, just send an email to time-keeper at freenet dot de.

Thanks a lot to anybody who supported me.
time keeper Send private email
Sunday, August 14, 2011
 
 
Sorry - missed this thread due to holiday season.

Yes, we would be interested in your code - would you like to share it with our community? If so, I can setup a wiki page for it?

Let me know...
Guy Pardon Send private email
Friday, August 19, 2011
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics