3

Is there anyway to add some logging or a behaviour to the WCF routing list so that I can log when the routing has made use of an endpoint on a backup list?

     <filterTables>
        <filterTable name="RoutingTable">
          <add filterName="Filter1" endpointName="EP1" priority="0" backupList="FailOver"/>
        </filterTable>
      </filterTables>
      <backupLists>
        <backupList name="FailOver">
          <add endpointName="EP2" />
        </backupList>
      </backupLists>

Could a behaviour somehow log which endpoint had finally been used by the routing service?

4

1 回答 1

0

尝试创建服务行为(或端点行为并在所有端点上配置行为)

连接消息检查器 IClientMessageInspector

在构造函数中传入端点

在 BeforeSendRequest 方法上记录消息和端点

public class MyClientMessageInspector : IClientMessageInspector
{
    private ServiceEndpoint _endpoint;

    public MyClientMessageInspector(ServiceEndpoint endpoint)
    {
        _endpoint = endpoint;
    }

    public object BeforeSendRequest(ref Message request, IClientChannel channel)
    {
        Log(request, _endpoint);
        return null;
    }

    public void AfterReceiveReply(ref Message reply, object correlationState)
    {
        //no-op
    }
}

然后您想将检查器应用于行为并附加到路由器

于 2012-10-18T09:30:17.837 回答