I need to audit properties of a JCR Node before the OTB deleted workflow physically deletes the node.
AEM provides a few ways to listen to deleted events. I've tried both the EventListener and a ResourceChangeListner. Both scenarios alert my code when a delete is triggered. However, I receive a "does not exist" when performing a session.getNode on the onChange path.
To validate I'm using the correct session/user/etc, I tested that I AM able to retrieve the node's parent. So, this proves I have the correct permissions and my listener is being informed after the node is already gone. Also, I have seen this work at least once so this is, obviously, a race condition. Sometimes I am alerted before the node is gone sometimes I am not.
So, how do I guarantee my code will be called before the JCR Node is actually gone?
Before you reference this post, I am applying solutions #2 and #3. Both have the same race condition result. #1 doesn't describe how to tie into the existing OTB AEM 'delete' 'workflow', is that possible?