Service station: Build WCF router, part 2nd

Source: Internet
Author: User

In the "Service Station" section of April 2008, I introduced you to how to create a simple router that enables transparent flow of messages between the calling client and the target service. In this process, I reviewed important windows®communication Foundation (WCF) Addressing and message filtering semantics, and you can learn how to design a router convention to handle untyped messages to And how to configure bindings and behavior to allow messages to be delivered without the router processing. In this installment, I will continue to discuss this topic and introduce more implementation details when using a more practical approach to routers.

Delivery Router Scenario

In part 1th, I have mentioned that when inserting a delivery router between a client and a service, the client relationship is to the target service, not the router. Although you must use a transport protocol and a message encoder that the router understands to send messages, the entire contents of the message, including security headers and reliable sessions, are not handled by the router. Several scenarios where the delivery router may be applied are load-balanced, content-based routing, or message transfer.

Load balancing and assignments for server resources are ideal for Network Load Balancing (NLB) devices, but are more appropriate for hardware load balancing devices. Also, a WCF router is useful for load balancing in the following situations: the environment that hosts the service does not have these expensive devices; the physical infrastructure of the installation service is not directly controlled by you; you need to route based on domain-specific logic; The application invokes only lightweight routing solutions that are easy to configure. This type of WCF router can be used to distribute messages to services in multiple processes that are dispersed across the same computer or to services distributed across computers.

Regardless of the distribution model, a load-balancing router must use several core functions. The service must be registered to the router in some way so that it can be included in the load assignment. Routers must be able to determine the service type and associated endpoints so that messages are forwarded correctly. Routers must have algorithms that assign loads, such as a typical loop method or route in some form or priority.

Sometimes, distributing messages between services is based on message content, not on load balancing. content-based routers typically check the message header or message body to obtain routing information. For example, a message sent by a client with a valid license key may be forwarded to a large pool that contains a server computer with high processing capacity, and messages from clients with a trial license will be forwarded to a small pool that contains a weaker server. In this case, the router should not only understand the forwarding target of the message, but must be able to examine each message (the header or body content of the message) and then determine the forwarding target of the message. The following sections discuss the related routing features that support these scenarios.

Forwarding by Action Header

Messages received on a router have two addressing headers that are useful when forwarding messages to the correct service:

The To header indicates the name of the endpoint. If this header matches the target service and does not match the router, the URL of the service endpoint of the message destination address is indicated.

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.