WCF routing backuplists - logging when they are used
Is there anyway to add some logging or a behaviour to the WCF routing l开发者_高级运维ist 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?
try creating a service behavior (or endpoint behavior and configure the behavior on all endpoints)
hook up a message inspector IClientMessageInspector
pass in the endpoint in a constructor
log the message and the endpoint on the BeforeSendRequest method
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
}
}
then you want to apply the inspector to a behavior and attach to the router
精彩评论