Dynamic CRM 2013 Plugin Event execution pipeline a

2019-08-12 16:17发布

I have couple questions please.

1- When plugin A triggers on an event and caused another plugin B to trigger, does Plugin B executes in the same Event execution pipeline as plugin A?

2- If the above is true and plugin A and Plugin B executes in the same Event execution pipeline do they both have 2 minutes to complete (since the maximum execution time of a plugin in dynamic CRM is 2 minutes) or each one of them has 2 minutes to complete which makes the total execution time allowed for both of them to complete is 4 minutes?

Thanks.

2条回答
姐就是有狂的资本
2楼-- · 2019-08-12 16:50

Plugin B will execute in a child pipeline of plugin A.

In Dynamics CRM 2011 the concept of parent and child pipelines was abandoned in an attempt to simplify plugin development, but under the hood they still exist. You can find out in which context your plugin is executing be checking the IPluginExecutionContext.ParentContext property.

E.g. when your plugin is registered for an Update message the parent pipeline can actually appear to be running in the context of an Assign or SetState message. Also, when custom plugin code is doing an update on a record, the update will be executed in a separate child pipeline.

In the sandbox the root pipeline has to complete within 2 minutes. For synchronous plugin steps this means all subsequent child pipeline tasks also need to be completed within that window.

Asynchronous plugin steps however do not play a role here, because these are executed in a separate process. Keep in mind plugin code cannot create child pipeline instances endlessly. In order to prevent endless running loops the system allows plugins to step no more than 8 levels deep. You can check this with property IPluginExecutionContext.Depth.

查看更多
手持菜刀,她持情操
3楼-- · 2019-08-12 16:52

In a plugin context that is not true, but i guess depends on how you register the plugin, if you perform a create operation from plugin A, and plugin B is triggered on that operation, if plugin B is synchronous (pre-validation, pre-operation), then plugin A needs to wait for plugin B to complete. Plugin B Still will have the 2 minutes window to complete, probably you will have a slight bigger window then 2 min - plugin A execution time, but when plugin A will get terminated because it passed it's execution time, plugin B will get terminated after his own 2 min limit (i'm imagining a roll-up scenario).

I guess the answer for you is no, they don't get Executed in the same event, but for the total execution time depends on how you register Plugin B, if synchronous or asynchronous.

查看更多
登录 后发表回答