Sponsored By Aspose - File Format APIs for .NET


What’s the difference between a message and an event

MassTransit has hit 0.6 RC1

On the Elegant Code Cast, I was asked what the difference was between a message and an event, and I really wasn’t happy with my answer. Well as luck would have it I recently started reading ‘The Power of Events’ in which the author gives a very good explanation (Below is a brief summation).

A message is just a structure. This structure could be as simple as the string ‘BUY’ or ‘SELL’ or it could be a complex structure like an object graph serialized to JSON. This is the message.

An event adds the components of ‘significance’ and ‘relativity’. Significance in this case is that the ‘message’ signifies some activity. The event’s form (again the message part) should contain data describing the event it signifies. Relativity is that it is related to other activities by time, causality and aggregation. Ok, so that introduces some other concepts. Time is easy, it happened on 12/31/2008. Causality is asking what caused this message. In MassTransit (MT), I am thinking of implementing this by placing the name of the message that is currently active in the message headers if you published any messages. Lastly, we have aggregation, if event A signifies the activity of the set of events B1, B2, B3… then A is an aggregation of the events Bi.

I look forward to finding ways to apply the thoughts and patterns in the book to MT in the near future. As for now though, 0.6 has hit RC status, and we are looking for feedback. So please pull the code down and run the samples. Let me know what you find and/or think.


About Dru Sellers

Sr. Software Engineer at Dovetail Software.
  • Maale Rachitha28

    ok not bad

  • Zinovate

    I’m looking forward to your finding, looks like a great addition to MT.

  • http://blog.componentoriented.com D. Lambert

    Ok, here’s a really gross oversimplification: messages and events are mirror images of one another, differing mainly in point of view.

    A message is an instruction — typically directed at a single recipient. When you send a message, you usually expect the recipient to do something about it (or with it).

    An event is a notification that something has happened, often multi-cast to anyone who’s interested. If you raise an event, it’s not unexpected for the recipient(s) to throw the event away because they may not be interested in it.

    There are probably a dozen ways to poke holes in this if you want to, but I thrive on oversimplification, so it works for me.