【问题标题】:WCF routing backuplists - logging when they are usedWCF 路由备份列表 - 使用时记录
【发布时间】:2011-08-07 22:40:53
【问题描述】:

是否可以向 WCF 路由列表添加一些日志记录或行为,以便在路由使用备份列表上的端点时进行日志记录?

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

一种行为能否以某种方式记录路由服务最终使用了哪个端点?

【问题讨论】:

  • 不确定你是否有一个扩展点。但是您可以使用 AppFabric 来监控您的客户端/服务。此外,您可以实现一个记录结果的自定义消息过滤器。

标签: wcf endpoints wcf-endpoint wcf-routing


【解决方案1】:

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

连接消息检查器 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
    }
}

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    • 2019-05-12
    • 1970-01-01
    • 2011-11-30
    • 1970-01-01
    相关资源
    最近更新 更多