11.07.2015 Views

y - Net Developer

y - Net Developer

y - Net Developer

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

amrameshreddy.blog.com252 CHAPTER 8 ■ IMPLEMENTING RELIABLE MESSAGING AND QUEUE-BASED COMMUNICATIONSramrameshreddy.blog.comProcessing IssuesProcessing issues have to do with the internal applications. When an error occurs, how is ithandled internally by the application? Let’s look at the main processing challenges:Messages are lost when an error occurs: Your message was received at the location. However,before it actually enters the system, an error occurred, and the message vanishedinto the network. How do you prevent this? Take a sell order for MSFT, for example, whichis received by the QuickReturns Ltd. application. Before the entire message was actuallyreceived, the network dropped some packets. Though you have sent the sell order and ithas been received at the server, it never entered the sell application.Interrelated messages are processed individually: You might have a set of messages thatneed to be processed as one transaction. However, these are treated as individual requestsby your system. Once again, the order to sell for MSFT and the order to buy for the energystock could be processed as a single transaction. Both the messages are related to eachother and need to be processed as such.Failure leads to an inconsistent state: The failure of the delivery of a message in some scenariosleads to an inconsistent state, whereby the client is actually expecting a response.However, since the service might be unavailable, this leads to the client continuing to waituntil a timeout occurs.Messages cannot be retired: Your sale of the marketing stock netted you more money thanyou expected, which you would like to apply toward the energy stock. So, you resubmitthe buy order with a changed quantity. How do you handle this scenario?The good news is that WCF enables you to overcome these challenges fairly easily with itsbuilt-in support for reliable messaging and reliable sessions. Moreover, providing this functionalityis fairly straightforward and does not require the services of a highly skilledprogrammer or reams of code.WCF makes adding reliability to the distributed application somewhat of a nonevent. Thisis especially true in an environment where both ends of the application are “likely” to be available,and it provides it at no extra cost or effort. The lack of a durable store for messages is areality for version 1 of the WCF implementation. Durability can be provided using MSMQ. Atthe same time, it is important to keep in mind that the reliable messaging feature set in WCF isnot a silver bullet, and it wasn’t designed to be one. The reliable messaging feature set in theend is about as reliable or unreliable as the network available to it.Reliable SessionsWCF reliable messaging provides reliability between two given endpoints regardless of thenumber of intermediaries between the two. This also includes intermediaries that might usealternatives such as HTTP proxies and ones that use SOAP. A great benefit in WCF is the abilityto switch from one transport mechanism to another using configuration settings. (For example,you start by using TCP with binary encoding and then change to reliable messaging overHTTP by modifying only the configuration files. It really is pretty much as simple as that.)WCF provides reliability and resilience. This means the following:ramrameshreddyramrameshreddy

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!