Wednesday, April 14, 2010

WCF 4.0 Routing Service –Failover

In this blog post I am going to show how to configure  WCF 4.0 Routing Service Failover option. I wanted to make sure not to confuse Failover Vs Load balancing.  Service Failover means when client can not reach or communicate with the Service the fall back route is called Failover. for example let say we have  hosted a WCF order Service as main Service, when client wanted to place an order it calls  PlaceOrder Operation  service once service receives the message it will process it.

suppose let say when client calls Operation (Method) on order service at that time if service not available in this case the PlaceOrder Operation message dropped between server and client instead of losing a message we will persist in MSMQ once service comes online we can push these order again to the service to process.

In Windows environment Microsoft Messaging Queue (MSMQ) Service mainly used for to build fault tolerance applications. MSMQ provides Public (as a Active Directory ) and Private Queues to persist the messages when client fails to communicate with service. Here we are going to use MSMQ Private Queue as a our backup service.

image

Now we need to create and host the following Service components.

  1. Define Service Contract and Implementation.
  2. WCF Order Service (Main service)
  3. Backup or Fail over Service
  4. Routing Service
  5. Client App

1) Service & Operation Contracts Definition:


image 

2) Order Service Hosting (Main Service)

image

Configuration

image

3) Backup or Failover Service Hosting

image[44]


image

4) Routing Service Hosting

image

image

     

Client Application

Create Windows console application and add Service Reference ( Order Service) .

image

     Now we need to modify the Endpoints which points to Router service instead of pointing to WCF Order Service.

Before Modification

image

    After Modification

image

image

        when main service is not running then Router service will send message to MSMQ .

 
image


Nandri(Thanks)

SreenivasaRagavan

1 comment:

Chris said...

Hey, this is a great example of how to create a routing service which could be used for many different purposes. However, if the routing service becomes unavailable, what do you do? I would assume that the routing service is stateless, so you could have multiple instances running in a farm and then use an NLB to distribute requests, but this seems a bit overkill. How do you ensure that the router stays available?

Thanks, Chris