Windows Communication Foundation Channel Shapes

The WCF channel model has three built-in archetypes for communication patterns.  These archetypes are the one-way pattern, unmatched two-way pattern, and matched two-way pattern.  Along with the archetypes are five interfaces, called channel shapes, that describe the send and receive methods for each pattern.  There is one interface for the client and server side of each pattern, except for unmatched two-way where the two endpoints have the same behavior.

In the one-way communication pattern, there is a unidirectional stream of messages between the client and server.  One end of the pair will have an IInputChannel for receiving messages and the other end will have an IOutputChannel for sending messages.  In a queueing system, you might have writers that put messages into the queue and a reader that processes messages from the queue.  Such a system would use the one-way pattern to indicate that there's no way to flow messages through the queue in the other direction.

In the unmatched two-way communication pattern, there's essentially a pair of one-way patterns welded together.  Each side has an input and output channel, joined together by an IDuplexChannel, that they can use independently.  Once you've established a bidirectional TCP connection, both sides of the connection can read and write messages at any time.

Finally, in the matched two-way communication pattern, there is still an input and output channel on both sides, but there's a semantic restriction on when messages can be sent.  The client can send requests to the server, through an IRequestChannel, and the server can send a reply back the client, through an IReplyChannel.  The client and server have to maintain this pairing because only one side is expected to talk on the channel at a time.  This is the model that HTTP uses for communication.

We've got some other obligations to take care of this week, but we'll spend next week looking at each of these interfaces in detail.

Next time: Get the Message