cancel
Showing results for 
Search instead for 
Did you mean: 

Transactions and Repository Actions

pjaromin
Champ on-the-rise
Champ on-the-rise
I have an external process that renders repository content based on node properties. This is facilitated by a repository Action that calls on this external application. The external application in turn makes calls back to the repository to gather key bits of information used in the rendering process before rendering the content and handing it as a stream back to the calling Action.

Thus far this has worked brilliantly.

However, now I've got an Action that generates a *new* node/document. It then calls out to the external process (this is actually facilitated through applying an Aspect with an onAddAspect behavior) to render the content.

Unfortunately, the new node is not yet available to the external process until after the action completes, which results in the rendering process failing.

I assume this is because the primary Action is executed within a single transaction and that the new node is only committed following the completed execution of the action. I've tried creating new user transactions and wrapping the node create in one hoping that this would result in the node being available to the external process before the main Action completes. I've also attempted to create the new node in a separate action call. Neither worked.

I've been thinking about this for some time and haven't hit upon a satisfactory work-around. Is there some mechanism that I might use in this situation? Is there some way to create a "deferred" process that would run following the Action commit?

Any insight/suggestions would be greatly appreciated.

Thanks!
5 REPLIES 5

mrogers
Star Contributor
Star Contributor
Could you gather your information prior to creating the new node?

The alternative is to trigger your external actions "post commit" so its called after node creation.

Or you could have some sort of queue of nodes to be processed?

pjaromin
Champ on-the-rise
Champ on-the-rise
Thanks for the response.

The alternative is to trigger your external actions "post commit" so its called after node creation.

Yeah, that's what I'm trying to do, but I don't know exactly how/where I can do this. The aspect (behavior) is already set to
new JavaBehaviour(this, "onAddAspect", NotificationFrequency.TRANSACTION_COMMIT)
.

I tried calling my own variation of the "CopyAction" that put the result in PARAM_RESULT within my main action. And then triggering the render. However the new node still isn't accessible until after the primary/calling action completes.

I'm assuming this is a transactional thing, perhaps it's more/different than that?

Or you could have some sort of queue of nodes to be processed?

Does such a queue exist that I could hook into?

Here's a quick/crude drawing to illustrate the sequence:

[img]https://dl.dropbox.com/u/35767566/alfresco-render-action.png[/img]

mrogers
Star Contributor
Star Contributor
Yes - that looks very much like the Alfresco Transformation Server.

pjaromin
Champ on-the-rise
Champ on-the-rise
Does the architecture for that system create a note and kick off external rendering within the same action?

What's done to make the newly-minted node accessible externally before the action returns?

-Patrick

pjaromin
Champ on-the-rise
Champ on-the-rise
I wound up putting the rendering process in a separate action that I execute asynchronously from within the main action.

This has worked so far, however I'm guessing I've set up a race condition where it's conceivable that the asynchronous action may for some reason execute before the main thread commits, no?

I really want this new rendition to replace the cm:content of the newly-minted node. Another alternative I suppose would be to trigger the re-render upon the first "download" request by modifying or replacing the default "Download" action for this custom node type.

Any other ideas?