WCF operation to post logs - should it be callback?
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.
So I think WCF Server should callback some method for all interested clients....
Should I use "CallbackContract" keyword to define one-way callback operation?
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?
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?
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
There are also specialized frameworks, like NServiceBus that solve broader problem of asynchronous messaging.
what you are asking sounds reasonable, have a look at this one: WCF Callbacks; a beginners guide
精彩评论