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.

CHAPTER 8 ■ IMPLEMENTING RELIABLE MESSAGING AND QUEUE-BASED COMMUNICATIONS 267ramrameshreddy.blog.comListing 8-8. Modifying the Clientusing System;using System.Data;using System.Messaging;using System.Configuration;using System.Web;using System.Transactions;namespace QuickReturns{class Client{static void Main(){// Create a proxy for the clientusing (TradeServiceClient proxy = new TradeServiceClient()){//Create a transaction scope.using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)){...}proxy.DoTrade("MSFT", "IBM", 60);Console.WriteLine("Selling 60 stocks of IBM and Buying MSFT ");proxy.DoTrade("ACN","ABN", 100);Console.WriteLine("Selling 60 stocks of ABN and Buying ACN ");// Complete the transaction.scope.Complete();As you have seen, you add a transaction scope around the DoTrade method in order tohave the service utilize the <strong>Net</strong>MSMQ binding correctly. You will learn more about transactionsin the next chapter. Now modify the App.config file for the client in order to use MSMQ,as per Listing 8-9.Listing 8-9. Modifying the Client App.config

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

Saved successfully!

Ooh no, something went wrong!