cancel
Showing results for 
Search instead for 
Did you mean: 

Delay in writing changes to DB

Bohemian_
Champ in-the-making
Champ in-the-making

We have non-nuxeo code that reads documents directly from the database. We fire this code (that updates a lucene index) based on nuxeo events (eg "document created"). In other places, we manually fire the non-nuxeo code with a 1 second delay.

In both cases, we are finding that often there is a significant lag between when we expect nuxeo to have written to the db, and the the changes actually being written.

Is there a way we can guarantee that our "other" code executes AFTER nuxeo has committed changes to the database? Any solution would do - eg a callback, changing a setting, anything.

We are using Nuxeo 5.3 and postgres 8.3. Upgrading nuxeo is not a viable option at the moment.

EDITED:

It seems I can not answer my own question, so I'll edit it here instead with how I solved this problem:

ACCEPTED ANSWER:

I solved this not by implementing PostCommitEventListener (and adding code that did not add any more value), but rather by setting postCommit="true" on my existing event listeners in listener-contrib.xml . That fixed everything.

1 ACCEPTED ANSWER

Olivier_Grisel
Star Contributor
Star Contributor

You should fire this code from an event listener that implements the PostCommitEventListener interface. This will only be called once the database has successfully committed the transaction hence rendered the changes visible to new transactions that starts after the commit.

For instance in Nuxeo the JmsEventForwarder class implements that interface to avoid the problems you mention.

View answer in original post

1 REPLY 1

Olivier_Grisel
Star Contributor
Star Contributor

You should fire this code from an event listener that implements the PostCommitEventListener interface. This will only be called once the database has successfully committed the transaction hence rendered the changes visible to new transactions that starts after the commit.

For instance in Nuxeo the JmsEventForwarder class implements that interface to avoid the problems you mention.