cancel
Showing results for 
Search instead for 
Did you mean: 

Using alf transactions with another app?

dynamolalit
Champ on-the-rise
Champ on-the-rise
Hi,

I have a webapp placed inside same tomcat where alfresco war resides. This webapp uses webscripts to call services from alfresco repository & does required tasks. Now i have following questions:
1. I have given
<transaction>required</transaction>
inside xyz.get.desc.xml. What does it mean? Will it take current transaction (created by user logged in using ticket generated for him) & perform the task & return. If so, i assume that it should work fine with n number of users.

2. Now i want to integrate my webapp transactions with alfresco generated ones so that i can have seamless integration w.r.t this. Is it possible? I am assuming that i can enter from my webapp into alfresco using a single transaction , perform tasks as saving content & return.

3. My idea is if anything breaks anywhere in webapp or alfresco , whole thing should rollback.

Till now not gained much momentum apart from RetryingTransactionHelper/User Transaction but not sure how to integrate it in webapp.

Any help will be highly  appreciated.
1 REPLY 1

openpj
Elite Collaborator
Elite Collaborator
inside xyz.get.desc.xml. What does it mean?
The transaction element is dedicated to manage how the WebScript should be executed in the Spring container and these are all the values that you can use to configure the element:

  • none - the WebScript will be executed without transaction support, this means that many repository features may goes in error (writing and admin)

  • required - the WebScript will be executed using an unique transaction and if it was defined previously it is taken from the container otherwise will be created a new transaction dedicated to the script. For each invocation you have an unique transaction for all the operations performed in this WebScript. This means that if you are storing more than one content, if there is an error in one of them, the container will rollback all the contents.

  • requiresnew - The WebScript will be executed in a new transaction anyway even if it was previously created
Remember that some methods must be executed in a transaction context, for example all the store operations and administration operations. This because all the operations are proxied by Spring and this is the right way to implement this type of operations.

Generally it depends on what you have to implement with your WebScript: if you only need to read you could use none, but some operations could fail. Otherwise you can use transaction to manage all the operations in an unique transaction or you can use requiresnew to require a new transaction for each request.

If you have to manage a WebScript in a different way, you can configure the WebScript without transaction and in your Java-Backed implementation you can use the RetryingTransactionCallback to manually manage transactions and change the behaviour of your WebScript:
http://wiki.alfresco.com/wiki/Web_Scripts


Hope this helps.