Dzi*_*mau 0 nservicebus nservicebus3
我有一个 NServiceBus 主机,它订阅了某个事件并有自己的处理程序(#1)。该主机还引用了一个程序集,该程序集包含同一事件的另一个处理程序 (#2)。我想从 NServiceBus 配置中排除处理程序 #2,但我无法删除引用的程序集。
重要:
1)我尝试使用此设置扫描:http : //docs.particular.net/nservicebus/hosting/assembly-scanning
2) 我使用 NServiceBus 版本 3.x
NServiceBus v3 扫描程序集。如果在运行时不需要该程序集,则只需将其删除,这样就不会被扫描。
仅仅因为它被引用并不意味着需要部署它。
排除文档中提到的程序集:
var allAssemblies = AllAssemblies
.Except("MyAssembly1.dll")
.And("MyAssembly2.dll");
Configure.With(allAssemblies);
Run Code Online (Sandbox Code Playgroud)
http://docs.particular.net/nservicebus/hosting/assembly-scanning#exclude-a-list-approach
只允许扫描一组特定的程序集或类型。基本上解析列入白名单的程序集或类型范围。
组件:
IEnumerable<Assembly> allowedAssembliesToScanForTypes;
Configure.With(allowedAssembliesToScanForTypes);
// or
Configure.With(assembly1, assembly2);
Run Code Online (Sandbox Code Playgroud)
类型:
IEnumerable<Type> allowedTypesToScan;
Configure.With(allowedTypesToScan);
Run Code Online (Sandbox Code Playgroud)
// Results in the same assembly scanning as used by NServiceBus internally
var allTypes = from a in AllAssemblies.Except("Dummy")
from t in a.GetTypes()
select t;
// Exclude handlers that you do not want to be registered
var allowedTypesToScan = allTypes
.Where(t => t != typeof(EventMessageHandler))
.ToList();
Configure.With(allowedTypesToScan);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
245 次 |
最近记录: |