File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Distributed Java and the fly likes Distributed Tx and Transactional File Access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "Distributed Tx and Transactional File Access" Watch "Distributed Tx and Transactional File Access" New topic
Author

Distributed Tx and Transactional File Access

Jay Rajani
Greenhorn

Joined: May 13, 2010
Posts: 3
Hi,

I am required to upload/access/move files and also store meta data into multiple database in a single transaction. If an exception is thrown, i have to rollback transaction in all databases and also from file system.

I am using JTA to manage transaction on multiple databases, but have to rollback file system manually in code.

Is there any way where we manage a distributed transaction involving file system and database at a time automatically through transaction manager?

I read about XADisk for transactional file access but am not sure whether it will satisfy my need.

Thanks,
Jay Rajani
Nitin Verma Nverma
Greenhorn

Joined: Jun 06, 2010
Posts: 9
Hi Jay,
If I rightly understand the requirement you posted, it must be possible to achieve it with XADisk. In brief, the transaction manager (TM) will need to enlist all the involved resources (multiple databases: [db1, db2, db3]...and the local file-system: [wrapped by xadisk]) with the "global/xa" transaction, and as the TM will pass through its 2PC phases, the involved resources (db1, db2, db3..., xadisk) will fulfill their xa responsibility.

Please refer to the User Guide. The User Guide is a work in progress, so please feel free to ask questions in the XADisk Usage Forum if you have any issues using XADisk, or contact the Project Owner(s).

Thanks,
Nitin (on behalf - https://xadisk.dev.java.net).
Jay Rajani
Greenhorn

Joined: May 13, 2010
Posts: 3
Hi Nitin,

Thank you for reply and consideration. You rightly understood my requirement.

I had a look on the guide initially but i could not find information on Connection factory configuration.

The jndi lookup of 'jca/xadiskcf' must be of connection factory. Am i right?

Can you suggest how to configure XADisk Connection Factory on JBoss Application Server?

Regards,
Jay Rajani

Nitin Verma Nverma
Greenhorn

Joined: Jun 06, 2010
Posts: 9
Hi Jay,
Sorry, but I haven't worked on JBoss much; I had tested XADisk on Glassfish (and its admin console facilitates creation of connection factories). Probably, you can refer to JBoss documentation on creating connection factories in JBoss; the same approach will apply to all JCA resource adapters including XADisk. In the meantime, I would also remain interested in deploying XADisk onto JBoss.

Thanks,
Nitin.
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

Hi "Nitin Verma CodeRanch",

Please check your private messages here for an important administrative matter.

Thanks,
Nitesh


apigee, a better way to API!
Nitin Verma Nverma
Greenhorn

Joined: Jun 06, 2010
Posts: 9
Hi Jay,
Out of my curiosity, I too deployed XADisk.rar on JBoss 5.1.0/Java5. The deployment revealed a few changes in ra.xml, which were not caught by Glassfish (Glassfish didn't complain those things). Then, it goes good and I also wrote a simple test-case (managed application) to give a sanity check with JBoss.

I have now uploaded the modified .rar, which you can download and deploy on to GlassFish, JBoss (and any other J2EE server) : Updated XADisk.rar

Now, about your question on connection-factory, I have used the Admin Console (/admin-console) to create a connection-factory for XADisk. It works fine. The links I followed were -
admin-console --> Resources --> Connection Factories --> Tx ConnectionFactories --> Add a new Resource --> Select Resource Template (XA Connection Factory) --> from here, you only need to give these details:
JNDI Name (eg "xadiskcf"), RAR Name ("XADisk.rar" if you haven't renamed after downloading), Connection Definition (org.xadisk.connector.ConnectionFactory). I haven't altered/set other options; so may not comment on them.

Once connection factory gets created, the following sample code in my servlet goes successfully:



On your other question. Yes, in the guide, "jca/xadiskcf" was used to refer to such a connection-factory only.

I hope that should help. Let me know if there are any queries.

Thanks,
Nitin.
Nitin Verma Nverma
Greenhorn

Joined: Jun 06, 2010
Posts: 9
Correction... <Please refer to my reply below>.
Nitin Verma Nverma
Greenhorn

Joined: Jun 06, 2010
Posts: 9
Please Note: Regarding my earlier replies, there are a few corrections.

First, please ignore the link to the binary (.rar) file and refer to the project page for new download links.
(Also ignore the link to the User Guide and refer to the project page for all updated information)

Second, there was a change in the package/class name for the connection factory classes. So, the one I mentioned earlier "Connection Definition (org.xadisk.connector.ConnectionFactory)", will not
work. Please refer to the user guide for updated information.

Sorry for the confusion.

Thanks,
Nitin
Nitin Verma Nverma
Greenhorn

Joined: Jun 06, 2010
Posts: 9
Please note that new URL for XADisk is http://xadisk.java.net/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Distributed Tx and Transactional File Access