在 BizTalk 中为隔离适配器启用默认应用程序域有什么影响?

What are the implications of enabling the Default application domain for isolated adapter in BizTalk?

我们最近在 BizTalk 中遇到以下错误

There was a failure executing the receive pipeline: "Microsoft.BizTalk.DefaultPipelines.PassThruReceive, Microsoft.BizTalk.DefaultPipelines, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35” Source: “Unknown ” Receive Port: "CustomerAPI" URI: "/Service.svc" Reason: Attempted to access an unloaded AppDomain.

研究这个错误导致我们 Known Issues with the SOAP Adapter 说。

The default AppDomain hosting the SOAP adapter gets unloaded causing the host process to hang

Problem:

The process hosting the SOAP adapter hangs, causing all other Web services in the process to hang. This may result in the following error: There was a failure executing the response(send) pipeline: "Unknown " Source: "Unknown " Receive Port: TwoWayLatencyLoopBack_RxPort" URI: "/TwoWayLatencyRxSOAP/TwoWayLatencyWS.asmx" Reason: Attempted to access an unloaded AppDomain.

Cause

The SOAP adapter runs in the IIS process space. If more than one Web service exists in the IIS AppPool, then every Web service ends up having its own AppDomain.

By default all messaging engine objects are created in the first AppDomain (that is,. the AppDomain corresponding to the first Web service). If the first Web service is inactive for an extended period of time for any reason, IIS unloads the first AppDomain. When this happens, all services in the hosting process become unusable.

Resolution

To prevent the AppDomain from being unloaded, follow the procedure below:

  1. Click Start, point to All Programs, point to Microsoft BizTalk Server and then click BizTalk Server Administration.

  2. In BizTalk Server Administration Console, Expand BizTalk Server Administration, expand BizTalk Group, expand Platform Settings, and then click Hosts.

  3. From the list of Hosts, right-click the required host, and then click Settings.
  4. In the BizTalk Settings Dashboard, check Default application domain for isolated adapter under General tab.

When you do this, the BizTalk Messaging Engine objects are created in the default AppDomain instead of in their own AppDomains. Because the default AppDomain is never unloaded, the problem no longer occurs.

下面是该设置的屏幕截图。

我们在测试环境中启用了此设置并注意到内存使用和内存泄漏减少了,请参阅 Mark Brimble 的博客 BizTalk Host Settings – “Default application domain for isolated adapter” 了解更多详细信息。

启用独立适配器的默认应用程序域设置是否有任何缺点,或者启用此设置会在 BizTalk 中造成什么其他影响?

如果没有缺点,为什么不默认为所有独立主机启用此功能?

在单独的 AppDomain 中执行应该使它们之间设置的边界更加安全。它还使 IIS 更容易 free/release 资源而无需重新启动整个进程 - 如果特定 service/site 未在使用中,则其 AppDomain 可以比重新启动 w3wp.exe 更便宜地拆除。

但是,在这种情况下,BizTalk 似乎试图同时使用这两种方式 - 允许 IIS 通过使用多个 AppDomain 更好地管理 security/memory/assembly 加载,但也无论什么时候都继续使用默认的消息请求进来了。这似乎是一个设计缺陷,这使得很难看出您何时想要不选中该设置。