09-27-2016 04:48 AM
Hello,
I have been tasked to develop a feature that sends mail to specific users when a document has been modified.
Essentially, I use behavior policies and aspects. Aspect 'subscribable' is used.
I register the event-handler like this :
policyComponent.bindClassBehaviour(
NodeServicePolicies.OnUpdateNodePolicy.QNAME,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "subscribable"),
new JavaBehaviour(this, "onUpdateNode", NotificationFrequency.TRANSACTION_COMMIT));
My event-handler is like this :
public void onUpdateNode(NodeRef docNodeRef) {
...
}
My implementation is very close to what is proposed in :
- Reference manual,
- Jeff Potts' tutorial on behaviors.
My issue is : For a simple update (e.g. upload of a new version), the event-handler is called several times.
Why are there several notifications ?
I use Alfresco CE 5.0.d.
Thanks in advance for your help !
09-27-2016 09:21 AM
In this case the user is using the notification frequency TRANSACTION_COMMIT which should ensure the policy is only called once (per affected node) at the end of the transaction regardless of how often the node is updated during the transaction.
09-27-2016 06:07 AM
OnUpdateNodePolicy behaviours will be called every time you add/remove aspect ,set node type,add/remove/update property . So please check your operation carefully whether your operation fall into those categories
09-27-2016 09:21 AM
In this case the user is using the notification frequency TRANSACTION_COMMIT which should ensure the policy is only called once (per affected node) at the end of the transaction regardless of how often the node is updated during the transaction.
09-27-2016 09:18 AM
If you are using Alfresco Share probably when you drop new content, Share will update the node for creating new association instances for thumbnail and preview content.
09-27-2016 11:34 AM
Thanks for your answers,
As Axel said, with the notification frequency TRANSACTION_COMMIT, I expect the event-handler to be called only once.
That is not what I see in the logs.
10-03-2016 10:28 AM
Hello,
For those who are interesed in policies and behaviors, I made tests with following behaviors. I wanted to knwo what behaviors are triggered by document related events.
- ContentServicePolicies.OnContentUpdatePolicy
- ContentServicePolicies.OnContentPropertyUpdatePolicy
- NodeServicePolicies.OnUpdateNodePolicy
- NodeServicePolicies.OnUpdatePropertiesPolicy
The table shows the results :
10-03-2016 06:11 PM
One note of caution: This only applies to an unmodified. uncustomized installation of Alfresco without any custom rules, behaviours, web scripts and/or services set up that could in turn trigger additional behaviours with the changes they are applying to nodes. There is no guarantee for this observation to hold true between different Alfresco versions either as behaviour of Alfresco web scripts / APIs for Share UI actions may be changed due to feature changes or simple bug fixes.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.