Domanda

When an exception is thrown the data that is added to the datastore is not rolled back. Is this correct behaviour since it uses the filesystem? Or should it also roll back the data in datastore. I am using Spring 3.2. I have deployed Jackrabbit to JBoss 7.1.1. I am using JtaTransactionManager since I am also using a database. Edit:

After reading about JTA and Spring I added only this line to the Spring config file. Seems like it registers the necessary things. In the "test" that I have set up I store a file in Jackrabbit, then I throw an runtimeexception (and after that I would normally persisted to database but since the exception aborts it it never run that far, however that would be the normal case). All this happens inside one method in the service layer annotated with @Transactional. However after the exception is thrown I still see the file in the datastore, I tried with an empty datastore and I would expect the file to be gone after the exception is thrown, but it is still there. Is this correct? Is it only the meta data (which I don't know where are stored) that is rolled back?

<tx:jta-transaction-manager/>
È stato utile?

Soluzione

When Files are Added to the Datastore

Binaries are stored in the datastore very early, usually just after setting the binary property to a node (even if the node is not saved, and the change is still in the so called "transient space"). That means the file is added to the datastore even before the transaction is committed.

Files in the datastore will stay there until garbage collection is run. That means, even if the transaction is rolled back, the files will be kept.

To get rid of unreferenced files, you need to run datastore garbage collection.

How to Run Garbage Collection

As documented in the Jackrabbit wiki page about the datastore, "garbage collection is used to purge unused objects". This is a management task that you would need to add to your application. As a general rule, it is recommended to run garbage collection in the evening or at the weekend, when the system is not busy.

Garbage collection will basically traverse the repository and mark all files that are still in use, and at the very end will remove those files that were not marked (mark & sweep).

Altri suggerimenti

As far as I know (correct me if I wrong), the only way to use Jackrabbit with JTA is through the JCA connection using jencks. Have you looked at this post?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top