Channels send and receive messages. Channels are responsible for work at the transport layer and for WS-* protocol implementations, security, and transactional processing. Channels are highly composable–in other words, they can be stacked in various ways to create the functionality required for a given application. Channels are extensible, and the WCF application programming interface (API) is intentionally designed in a way that allows framework developers to create custom channels when necessary.
For the most part, channels are hidden from the mainstream application developer API. Framework developers, on the other hand, will frequently create custom channels as a means to allow messaging over custom transport or via a custom protocol that is not supported by WCF out of the box. Learning about channel internals is important for both the application developer and the framework developer. After all, channels are a key part of the internal plumbing in all WCF applications. This chapter explains channel essentials and is targeted to both the application developer and the framework developer.
As you’ve probably seen, the WCF API is fairly complex, and the channel layer is no exception. As with other parts of WCF, learning to use channels consists of two major phases: learning the type hierarchies and learning the execution environment. In my experience, the best way to learn to use channels is to spend some time learning the type hierarchies, and then build a simple channel and plug that channel into the WCF infrastructure. Spending too much time in the type hierarchies early on tends to be disorienting, and starting by building a custom channel without knowledge of the type hierarchies is virtually impossible and a sure path to frustration.
It is also important to note that production quality channels must have an asynchronous interface. If asynchronous programming is new to you, it is probably beneficial to brush up on asynchronous programming before writing your own production quality channel. In my view, a great reference is Jeffrey Richter’s CLR via C# (Microsoft Press, 2006).