Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for message inspectors in the callback channel #4607

Closed
lukasz-zoglowek opened this issue Apr 27, 2021 · 7 comments
Closed

Add support for message inspectors in the callback channel #4607

lukasz-zoglowek opened this issue Apr 27, 2021 · 7 comments
Assignees
Milestone

Comments

@lukasz-zoglowek
Copy link

Describe the bug
.NET Core version of WCF is missing CallbackDispatchRuntime.MessageInspectors API on ClientRuntime class and IDispatchMessageInspector interface.

To Reproduce
In legacy .NET we have following code for logging messages (outgoing and incoming messages from callback channel)

var messageLogger = new MessageLogger();
clientRuntime.MessageInspectors.Add(messageLogger);
clientRuntime.CallbackDispatchRuntime.MessageInspectors.Add(messageLogger);
clientRuntime.ClientMessageInspectors.Add(messageLogger);


public class MessageLogger : IClientMessageInspector, IDispatchMessageInspector
{
    public void AfterReceiveReply(ref Message reply, object correlationState)
    {
        // Log outgoing messages
    }

    public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
    {
        // Log incoming messages from callback channel
    }
}
@HongGit HongGit added this to the 6.0 milestone Jun 23, 2021
@HongGit
Copy link
Contributor

HongGit commented Jun 23, 2021

@imcarolwang can you please work on this implementation at your earliest convenience?

@tapizquent
Copy link

Having access to AfterReceiveRequest and BeforeSendReply from IDispatchMessageInspector is critical to ensuring messages can be modified.

Is there any workaround to using BeforeSendReply with the current exposed APIs?

@mconnew
Copy link
Member

mconnew commented Aug 25, 2021

@tapizquent, there is a hideous workaround. You can create your own custom bindingelement and insert it in the channel stack at the top. It would see every message coming in and every message going out, including client initiated requests. An IDispatchMessageInspector is a lot easier as it only gets called for callback methods. We're going to add this for the .NET 6 release timeframe, but you can keep using it on your current version of .NET that you are using as WCF doesn't depend on the latest .NET release.

@mconnew
Copy link
Member

mconnew commented Sep 23, 2021

This will be available in RC2

@HongGit HongGit closed this as completed Oct 13, 2021
@StephenBonikowsky
Copy link
Member

@mconnew is there a merged PR we can link this to?

@mconnew
Copy link
Member

mconnew commented Oct 27, 2021

The PR was #4699

@StephenBonikowsky
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants