我遇到了一个面试问题,我从朋友和同伴那里得到了不同的答案,所以我想我会在这里问。
我们通常使用插件排名来定义不同插件执行的顺序,以克服依赖性问题。
题
如果一个实体在同一个事件和同一个阶段注册了多个插件(来自不同的dll或相同的dll),并且所有插件的Rank / Order都是1 - 它们触发的顺序是什么?
它们都是并行执行的吗?它取决于首先注册的插件等吗?如果可以,请指出任何MSDN参考。
提前致谢。
您好,请找到以下从MSDN
复制,
执行顺序:
Specifies the order, also known as rank, that plug-ins are executed within a
pipeline stage. Plug-ins registered with an order value of 1 are executed
first, followed by plug-ins registered with an order of 2, and so on. However,
if there is more than one plug-in in a stage with the same order value, then
the plug-in with the earliest compilation date is called first.
作为一种良好的做法(也是一个很好的面试答案),依靠CRM产品的编译日期逻辑的后备计划是不安全的。根据我们的要求明智地使用执行顺序。
如果这个CRM逻辑明天发生变化,或者Dev团队为同一个程序集/消息/阶段添加了一个新插件,它必须在其他插件之上或之间执行,那么依赖性问题就会增加。所以设计得很好。
当所有其他因素相等时,SdkMessageProcessingStep.SdkMessageFilterId管理插件执行的顺序。
编辑日期是在几年前记录的。如果它是真的那么IDK,但它现在不是。