DDDD: Pipes (Producers) and Filters (Consumers)

[UPDATE: This article may be better titled as Pipes (Publishers) and Filters (Consumers) because as of a recent message group thread, the concept of "Produce" has been renamed to "Publish".]

As I really started looking at the interface for IConsume and IPublish (sorry, I can't shake putting "I" on interfaces), I was slightly perplexed. In essence, it appears that these two methods could do the same thing: Consume(Message) and Publish(Message) because the method signature is identical except the name. If they have the same signature, why have a different name or even a separate interface? It must be something related to the intent of each interface.

So, why do we need both? Pipes and filters. They both work with some kind of stream like grep does. So which is which? Well, the aggregate root of a domain implements IConsume, which means it's a filter, because it takes a message and processes it, transforms it, etc.

This means that IPublish is the pipe portion—it takes the message and routes it in a certain direction—perhaps across process or network boundaries (serialization) or perhaps thread boundaries, or whatever. It may not necessarily interpret the message data itself (which is what a filter does), it just sends the message where it's supposed to go.