indows Communication Foundation (WCF) endpoints often need to guarantee delivery. Take, for example, a WCF-based e-commerce application that accepts a credit card entry and performs some basic validation of the customer. At that point, the application must
guarantee that the transaction gets processed. That's why developers have to ensure that their WCF endpoints are durable. This article shows you how to do just that.
Using an order-processing service as an example, this article demonstrates the necessary concepts for making a WCF endpoint durable. It offers a thorough explanation of how to write a reliable and durable WCF service in a Windows Server cluster.
You will need to be familiar with WCF to follow along. For an introduction to WCF, please refer to the DevX article "The Windows Communication Foundation: A Primer." For a tutorial on the configuration entries needed to ship a WCF service, which may also be helpful, read my previous DevX article "Configuring WCF Services and Getting Them Ready to Ship."
Reliable, Guaranteed, and Durable Are Not Synonyms
Before diving into the details, let’s clear up some basic terminology. In this article, reliable and guaranteed are used interchangeably, but the terms reliable, guaranteed, and durable often mean different things to different people. To understand these concepts better, consider a scenario involving FedEx. Suppose Company X wants to send a billion-dollar retirement check to Mr. Z. Someone at Company X puts the check in a secured, tamperproof envelope and hands it to a FedEx courier.
If Company X chooses Reliable/Guaranteed (AKA, Fire and Forget) delivery, it trusts the FedEx courier and doesn’t worry about delivery beyond simply handing the check over. As such, it doesn't pay any additional fee or take any additional measures to ensure that the delivery does happen. It relies on FedEx's checks and balances to ensure that as the check bounces from one vehicle to another and passes through different hands it reaches Mr. Z. All Company X cares about is the tracking number; as far as it's concerned the transaction it complete at handoff.
On the receiving end, FedEx tries to deliver the check. If it finds no response, FedEx puts the check back on the shelf and tries to deliver it another day. If a couple of other delivery attempts fail, FedEx notifies Company X of the failed delivery.
Durability is about making sure that the steps in a transaction happen. In a durable delivery process, Company X would not deem the transaction complete until the check is delivered safely to Mr. Z and he deposits it. If the delivery fails, then Company X puts the check back in the queue (that may not happen in the real world though).