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.
Now we need to create and host the following Service components.
- Define Service Contract and Implementation.
- WCF Order Service (Main service)
- Backup or Fail over Service
- Routing Service
- Client App
1) Service & Operation Contracts Definition:
2) Order Service Hosting (Main Service)
3) Backup or Failover Service Hosting
4) Routing Service Hosting
Create Windows console application and add Service Reference ( Order Service) .
Now we need to modify the Endpoints which points to Router service instead of pointing to WCF Order Service.
when main service is not running then Router service will send message to MSMQ .