Hi to everybody,
I write a lot of values into JCR /var/xxx and close the operation with a ResourceResolver commit and a refresh.
My question was: does AEM perform the persistance operation asynchronously and should I wait with a EventHandler for these values? Or is it possible to continue without waiting?
Thanks in advance
Solved! Go to Solution.
ResourceResolver is generally not thread safe! As a consequence, an application which uses the resolver, its returned resources and/or objects resulting from adapting either the resolver or a resource, must provide proper synchronization to ensure no more than one thread concurrently operates against a single resolver, resource or resulting objects.
thanks for clarification. Does perform .commit() a synchronious write into JCR?
This means, when I wake up the 2nd thread instantly after calling .commit() and when thread 2 is reading the data after calling resourceResolver.refresh(), get thread 2 all data? Or is it neccessary to sync thread 2 with a EventListener on JCR Level?
Actually it's both synchronous and asynchronous :-)
The write to the repository is happening synchronous. That means that after the .commit() returned you can read the data from the repository. Also the property indexes are updated synchronously.
But the lucene indexes are updated asnychronously. That means that a JCR query immediately after the commit() might return the nodes you have just updated (depending on the type of the index which is used for that specific JCR query).