I'm beginning my exploration of NServiceBus, RabbitMQ, MassTransit and EasyNetQ.
One detail I specifically want to understand is how to ensure a custom set of meta-data is always sent with every published message?
For example, regardless of what a message producer publishes, I may want to ensure that the following pieces of information are always sent as part of the message:
- TimeStamp
- Workflow Name
- Priority
It doesn't really matter what the meta-data is, what is important is having the option or ability to forward along such arbitrary information.
I like the idea that the namespace and class name of the message sent by a producer is automatically translated into the "routing key" of the message. However, in order for additional meta-data to be attached to the message, it may be necessary to have some kind of "pre-publish" hook-point that allows the arbitrary message to be converted into the payload of a wrapper object, as such:
public class BaseMessage {
//a couple fields of meta-data that every message should have.
public string TimeStamp;
public int Priority;
//The payload is the real message that the consumer cares about
//and can be any format (JSON, XML, etc).
public string payload;
}
In this case, I don't want the "routing key" to contain either the name or namespace of the BaseMessage
. The payload type, before it was serialized, is what that "routing key" should be based on.
Of course all of this also presupposes that the consumer has some convenient way to de-serialize both the BaseMessage and the payload.
So which of the tools I listed supports this kind of need? Please show example syntax where applicable.