What is messaging? When a producer sends a message to a consumer over a channel/transport.
What kinds of messaging are there? Point-to-point (P2P) and publish/subscribe. An example of the former is writing a file to hard disk – you don’t expect that file to appear in several places. The latter is used in mailing lists.
P2p can be active or passive. In the active scenario, the consumer gets the message immediately. Example: Watching a web page in your browser. You wouldn’t want the browser to tell you “go drink some coffee, I’ll let you know when it’s done.”
In the passive case, the message is stored somewhere so the consumer can process it at its leisure. You mailbox is an example for this (off- and on-line).
All messaging systems are only one-way. If the consumer can reply, the implementations always make the consumer a producer. Think web sites. Your browser (producer) send a message to the server (consumer): “I want to see this page”. Then the server becomes the new producer when it sends data to the browser (new consumer).
As you can see, we’re using message based system all the time. What makes them so interesting?
They are easy to set up, easy to maintain and easy to make fault tolerant. For example, you can have these generic kind of consumer in your network:
- Transformers – Turn one kind of message in another. XML to JSON or CSV, binary data to text, insert data into a database
- Filters to ignore some messages without changing the code of the consumer
- Routers to redirect messages to consumers that are interested in them
- Splitter that can copy (parts of) a message to several consumers (distribute part in map-reduce framework)
- Aggregators that can join several messages into a single one (reduce part in map-reduce framework)