Basics: Building a queued WCF response service

Source: Internet
Author: User
Tags msmq

Original address: Http://msdn.microsoft.com/zh-cn/magazine/cc163482.aspx

Directory

Queued Call

Response Service

Design Response Service Contract

Using Message headers

ResponseContext class

Client programming

Server-side programming

Response Service Programming

Conclusion

Windows Communication Foundation (WCF) enables clients and services to communicate in a connectionless manner. The client publishes the message to the queue, and the service then processes the messages later. This interaction creates a different programming model from the default request/response pattern, which is expected to better balance the load, increase usability, and compensate for the benefits to the user. This column begins with a brief introduction to Windows®communication Foundation's queued invocation capabilities, and then presents an interesting question, "How to get results from queued calls," and then through some cool Windows communication Foundation programming techniques and the helper classes I've written to find a solution.

Queued Call

Windows Communication Foundation uses netmsmqbinding to support queued calls. Windows Communication Foundation transmits messages not through TCP or HTTP, but through Microsoft® Message Queuing (MSMQ). Instead of sending Windows communication Foundation messages to an online service, the client is sent to an MSMQ queue. The objects that all clients face and interact with are queues, not service endpoints. Therefore, the invocation is inherently asynchronous and not connected. These calls are not executed until the service processes messages at some point in the future.

Note that Windows communication Foundation messages do not map directly to MSMQ messages. An MSMQ message can contain one or more Windows communication Foundation messages, depending on the contract session mode. For required session mode, multiple Windows Communication Foundation invocations can coexist in an MSMQ message, and for allow or disallow session mode (used by single invocation and single-instance services), each Windows communication The Foundation call will be in a separate MSMQ message.

As with each Windows communication Foundation service, the client interacts with the agent, as shown in Figure 1. Because the agent is configured to use MSMQ bindings, the agent does not send Windows communication Foundation messages to any particular service, but instead converts the call to an MSMQ message and then publishes the messages to the queue specified by the endpoint address.

Figure 1WCF Queued Call architecture

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.