In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "how to use the WCF framework", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use the WCF framework" this article.
The framework is actually a standardized process, which can make our process very clear and the code more standardized. Let's introduce the publish-subscribe implementation process in the WCF framework. I not only provide publish-subscribe services and client examples, but also provide a general framework that automates publish-subscribe services and adds support for all applications. To build such a framework, you first need to break down the interfaces that manage publish-subscriptions, and then provide separate contracts for temporary and persistent subscriptions as well as publications.
WCF frame reader type
We can even define two types of subscribers: temporary subscribers are those who run in memory, and persistent subscribers are those who persist to disk, which represent the time at which the service invokes the event. For temporary subscribers, you can use a two-way callback mechanism to pass callback references to running services. Persistent subscribers need to record the subscriber address as a reference. When an event occurs, the publishing service invokes the address of the persistent subscriber and passes the event to it. Another significant difference between the two subscription types is that we can store persistent subscribers on disk or in a database. This allows the subscriber to be persisted when the application is closed or the machine crashes or restarts. This process allows subscriptions to be configured administratively. Obviously, when we close the application, we cannot store temporary subscriptions, but we need to explicitly create temporary subscriptions each time the application starts.
The WCF framework manages temporary subscriptions
Temporary subscriptions can be managed using the ISubscriptionService interface I defined, as shown in the example. Example manages the ISubscriptionService interface of temporary subscribers
[ServiceContract] public interface ISubscriptionService {[OperationContract] void Subscribe (string eventOperation); [OperationContract] void Unsubscribe (string eventOperation);}
Note that the ISubscriptionService interface does not recognize the callback contract that implements the endpoint it expects. As a general interface, it has nothing to do with a specific callback contract. Defining these callback contracts depends on how the application is used. By inheriting the ISubscriptionService interface, you can provide a callback interface in your application and specify the desired callback contract:
Interface IMyEvents {[OperationContract (IsOneWay = true)] void OnEvent1 (); [OperationContract (IsOneWay = true)] void OnEvent2 (int number); [OperationContract (IsOneWay = true)] void OnEvent3 (int number,string text);} [ServiceContract (CallbackContract = typeof (IMyEvents))] interface IMySubscriptionService: ISubscriptionService {} above is all the content of the article "how to use WCF Framework". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.