发布日志的 WCF 操作 - 应该是回调吗? [英] WCF operation to post logs - should it be callback?

查看:24
本文介绍了发布日志的 WCF 操作 - 应该是回调吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WCF 包含服务器端和客户端在我的情况下服务器是生成数据(日志)的程序.当一组新数据准备好发布时,应该通知多个订阅者.

WCF contains Server and Client side In my case Server is the program that produces data (logs). There are several subscribers that should be notified when a new bunch of data is ready to be posted.

所以我认为 WCF 服务器应该为所有感兴趣的客户端回调一些方法......

So I think WCF Server should callback some method for all interested clients....

是否应该使用CallbackContract"关键字来定义单向回调操作?

Should I use "CallbackContract" keyword to define one-way callback operation?

我需要的是 void Log(string) 方法,每次应该发布某些内容时,服务器都会为所有客户端调用该方法,如何根据 WCF 定义此类方法?

I need is void Log(string) method which will be called by server for all clients every time something should be possted, how to define such method in terms of WCF?

可能我应该避免回调",而是使用将返回新日志的 string[] getLogs() 方法?那么客户端可能会每隔一秒或两三秒调用 getLogs 方法来获取最后一个间隔的日志?

probably I should avoid "callback" but instead use string[] getLogs() method which will return new logs? then client may call getLogs method every one or two or three seconds to get logs for the last interval?

推荐答案

你描述的看起来像发布者/订阅者模式.看看这个:http://blogs.msdn.com/b/tomholl/archive/2008/05/17/building-a-pub-sub-message-bus-with-wcf-and-msmq.aspx

What you described looks like Publisher/Subscriber pattern. Check this out: http://blogs.msdn.com/b/tomholl/archive/2008/05/17/building-a-pub-sub-message-bus-with-wcf-and-msmq.aspx

还有专门的框架,例如 NServiceBus,可以解决更广泛的异步消息传递问题.

There are also specialized frameworks, like NServiceBus that solve broader problem of asynchronous messaging.

这篇关于发布日志的 WCF 操作 - 应该是回调吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆