我应该在哪里插入 WCF 才能在消息到达时收到通知?
我正在编写一个示例控制台服务主机,我希望插入 WCF 堆栈,以便能够在新消息到达时将消息打印到控制台,即使它目前不会被服务处理(因为服务正在工作)在之前的通话中)。 这是基于我的假设,即到达的消息由 WCF 排队,这是正确的吗?
此外,如果这很重要,我会使用 netTcpBinding。
I'm writing a sample console service host and I want to plug into WCF stack to be able to print a message to console when new message arrives, even if it won't get processed by the service at the moment (because service is working on previous calls).
This is based on my assumption that messages arriving get queued by the WCF, is that correct?
Additionally, I'm using netTcpBinding if this is important.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以编写自定义通道并将其插入到通道堆栈中的任意位置。 排队发生在 ChannelListener 中,它位于每个通道之间:
ChannelListener_1 -> 频道_1 -> ChannelListener_2 ->; 频道_2 -> 因此
,如果您要插入自己的通道侦听器/通道,您可以挂钩到您需要的流程的任何部分。 但请注意,消息内容可能无法读取,直到消息内容进一步深入堆栈并被解密。
You could write a custom channel and insert it into the channel stack at whatever point you want. Queuing happens in ChannelListeners, which sit between each channel:
ChannelListener_1 -> Channel_1 -> ChannelListener_2 -> Channel_2 -> etc.
So, if you were to insert your own channel listener / channel you could hook into any part of the process you need to. Note however that the message contents might not be readable until it gets farther down the stack and gets decrypted.
您可能必须为此编写一个自定义通道。 查看WCF 频道迷你书
You probably have to write a custom channel for that. Check out WCF Channels Mini Book