Sunday, July 19, 2009

WCF, delving deeper...

Windows Communication Foundation (WCF)... This has been a buzz word for quite a while now, ever since .net 3.0 beta was released. I wonder if many people actually realize what WCF provides and what the actual benefits are.

I think most people are like me and have used it in the traditional web services (asmx and SOAP) sense, which is basically a glorified RPC framework. The reason I say this is that once you add WCF as a reference it actually generates a proxy (which is a copy of the contracts) on the client. It will use this proxy to make any calls. This is fine in most normal situations but what else does WCF provide?

Well, in short it has abstracted the way we look at services. We are no longer bound to the infrastructure code of writing over a channel. Thus the service is ambiguous to what channel it uses (SOAP, TCP, MSMQ, REST, etc). It also provides a more elegant way of dealing with cross cutting concerns like security, exception handling, end point addressing, etc. Thus with WCF you can concentrate on writing the required business processes and worry about the hosting details at a later stage. Basically taking the "Junk" out of the code. That is great, but is there more?

In short, Yes! My colleague and I were creating our own framework to support generic Integration Pattern concepts like Channels, EndPoints, Routers, Pipe And Filters, Channel Dispatchers, etc. This framework would allow us to easily scale and re-use common components.

We asked the question: Can WCF solve our infrastructure and messaging concerns in a enterprise integration system? On the surface the answer was No. Like most people we saw it as a RPC framework. But after looking a bit deeper we realized that there was so much more to WCF than originally thought. It supports numerous Messaging concepts, built into WCF, that could help us extremely much.

It supports the following:
  • Channels (built in support for TCP, MSMQ, SOAP, REST and named pipe)
  • End Points (synchronous, asynchronous, and dual binding for some channels)
  • Channel Dispatchers
  • Poison Queues
  • Input and Output Queues
  • Routers
  • Pipe and Filters
  • Message Transformation
  • Transactions
  • Cross cutting concerns: security, exception handling, etc
  • Etc
These are just a few concepts of Enterprise Messaging Integration that WCF supports built-in. Unfortunately most books do not cover these kinds of topics. And most integration concepts are covered in Microsoft by technologies like BizTalk. It took some time to find relevant articles, but once we found it we were sold.

Here are two very nice articles to get you started which we found on MSDN magazine. These articles show you how WCF addressing works and how to build a simple pass through router, public subscribe router and even a content based router using a dynamic recipient list.

Part 1:
http://msdn.microsoft.com/en-us/magazine/cc500646.aspx

Part 2:
http://msdn.microsoft.com/en-us/magazine/cc546553.aspx

We are very pattern centric at our company and we are very pleasantly surprised that Microsoft have developed a framework which is so closely modeled to the Integration Patterns.

1 comment:

  1. Good to see you've changed your mind about WCF! ;)

    It does get some getting used to, but once you go WCF there's no turning back!

    ReplyDelete