We ran into a situation with Live Integration where we have multiple UserSaved / AddressSaved notifications fire for a user, causing multiple requests to the ERP per HTTP context. For example:
- Changing user data triggers 1 notification - UserSaved
- Adding a new address (without setting it as the default) triggers 2 notifications - UserSaved + UserAddress
- Changing the default address triggers 3 notifications - UserSaved + UserAddress (old default address) + UserAddress (new default address)
Since the XML for a user also includes the address info, we're sending the same information multiple times. When the requests fire fast enough, this can lead to duplicate data in the ERP.
Ideally, I like to have a single notification subscriber like AllUserDataSaved that I can handle to submit the data to the ERP. Would that be possible somehow?
If not, I was thinking about doing this custom, as follows:
1. Handle UserSaved and just add something to HttpContext.Current.Items to indicate there's a pending change
2. Do the same for UserAddressSaved
3. In a late subscriber like OnOutput or so, fire a custom notification like AllUserDataSaved
4. Handle AllUserDataSaved and send all data to the ERP.
Would that be a good approach? Any pitfalls I need to be aware of?