I was impressed with the presentation made by Ritesh Khotari at the Atlanta .NET User Group on 10/25/2010. The topic was on WCF 4.0 discovery and routing services. I have been working with WCF services (and RIA services), but I hadn’t learned much of the scope of what WCF really can do. In a way, it was so easy to set up a web service project in Visual Studio to send and receive data that I didn’t take the time to learn what was available for the bigger picture of SOA architecture using WCF. Ritesh’s presentation definitely changed that for me.
WCF Discovery
Ritesh walked us through a simple printer example that demonstrated the use of discovery. He created two simple projects, one (client) that sent a line of text and another (“printer” service) that received the text message and displayed it. He then made the service “discoverable” so the client could view if it was available. Then he created copies of the service with different end points to show multiple “printers” available. By turning the services off or on, the client app could show the user which “printers” were in service or off-line. Each instance of the “printer” service had a different endpoint and broadcast its availability. This reminded me of what MEF and PRISM can do for application modules and components. The loose coupling of services to client applications or other services is pretty easy to do with WCF and really can help with scalability, flexibility, and maintainability. Ritesh added discovery to the client and service projects mostly via additions to the web.config files, but you can also do the same thing in code.
WCF Routing
Ritesh then went on to discuss WCF routing. When the number of services in a system gets large, it becomes difficult to maintain because the services can be moved from device to device, added, deleted, or addresses can change. A good approach to mitigate this problem is to use a service router that serves as a centralized place to control traffic to available services. This is one of many approaches, but Ritesh made a compelling argument for using WCF routing by showing another simple example. He created a routing service project and showed how to make changes to service endpoints by making changes to the web.config. Then he showed how to add rules to the routing service, again in the web.config, that would allow routing according to specified conditions being met. His example showed how different incoming messages to different services depending on who was sending them or where the message was sent from.
Here are some of the key points I got out of the presentation:
- WCF has facilities beyond just sending and receiving messages between applications and/or services
- WCF discovery allows loose coupling of applications with services that can allow better SOA architectures to be implemented.
- WCF routing is a great way to create SOA implementations that scale and are easier to maintain as the number of applications, services, and devices increase.
Use WCF discovery and routing to make your SOA system better in many ways.
When I get a link to download Ritesh’s code, I’ll add it to this post.
Thanks, Ritesh!