I believe that if you have ever written a CRM plugin, you are aware of the event execution pipeline (https://msdn.microsoft.com/en-us/library/gg327941.aspx) and that the operation is run in transaction which means that if there will be any exception, the whole transaction will be rolled back. Pre-operation plugins and Post-Operation plugins are also run in transaction, so if there will be an exception raised by the plugin, changes will not be reflected in CRM.
However when the plugin is writing events to another system (like service bus, eventhub, kafka etc), this creates an issue, rollback happened in CRM database however the external systems have no way of knowing it. Is there a way to trigger a plugin (or custom code) on the commit or rollback of these transactions. So that it helps to send a compensation transaction to the external system?
When I decompiled the Microsoft.Crm.Core.dll I find CrmTransactionEventManager where we I see functionality to add PostCommitTransactionEventHandler, however not sure if we can utilize this as of now.
*This post is locked for comments