Never over Architected

Day and life of Software Architect Edward Chan

03
Dec 2009

WCF 4.0 - Two Features I'm excited about!

Message Pump as a Service – Routing Service

Since WCF 3.0 many developers (including Sasha and myself) needed to implement a message pump (or message router) which basically takes messages from an input channel and puts them on an output channel. This is useful for various scenarios which include:

  • Basic Message Routing
  • Protocol Bridging
  • Service Aggregation
  • Versioning

WCF 4.0 now ships with a Routing Service which fully supports message routing, thus decoupling the client from the server. This service supports:

  • Basic message routing based on a configured filter table.
  • Protocol bridging including transport conversion, SOAP version conversion etc.
  • Security decoupling and impersonation.
  • Error handling – configure alternate service endpoints in case of failure.
  • Transactions – flow transactions and control of transactional queue reads (as opposed to the destructive reads done in WCF 3.0 and 3.5 which delete the message when it is read).

Service Discovery

Discovery is the ability to publish a service’s endpoint metadata and discover services using well defined criteria. This is very useful both during design time to find available service and during runtime to allow reduced configurations, location agility and dynamic/self-healing applications. This service is an implementation of WS-Discovery and is standard interoperable.

Discovery comes in a couple of modes:

  • Ad-hoc Discovery – No central discovery server, and discovery is performed via multicast messages.
  • Managed Discovery – A discovery proxy is used to facilitate discovery. This suppresses the use for multicasting, and it also allows us to expose our own service repository to all clients in a standard way.

WCF 4.0 provides a full implementation for the ad-hoc mode and all of tools and contracts for building your own custom managed discovery mechanism. “DiscoveryProxy” is the base class required for creating a discovery service.

Making a service discoverable is very simple – just add a “ServiceDescoveryBehavior” and a discovery endpoint (such as “UdpDiscoveryEndpoint”) and you’re good to go. On the client side all you have to do is use a “DynamicEndpoint” instance, use it to create an instance of your service and you’re done!

Adding announcements to services is just an easy – all you have to do is add an announcement endpoint and that’s it. This gives you a very impressive ability for the client to respond to service availability on the network.

These are the two main features in WCF 4.0 I'm super excited about. Back in the day (last year) I had to hand build my routing service myself, and anybody who did what I did knows how much of a pain it can be.

Then adding a discovery service on top of your routing service can make for a pretty mean and lean pub/sub system.

Excited to try out these new features...