Command/event metadata

134 views
Skip to first unread message

seagile

unread,
Sep 5, 2010, 2:36:38 AM9/5/10
to DDD/CQRS
What are the motivations to treat metadata as message headers vs.
message body data?
Do you store the cmd/evt in the same form as they get sent/published
(i.e. with or without metadata)

// header (modelled as an envelope)
public class Message {
public MessageHeader[] Headers { get; set; }
public ICommand Body { get; set; }
}

// body (modelled metadata as part of the command)
public class XXXCommand {
public Guid CommandId { get; set; }
public DateTime DateCreated { get; set; }
}

This has more todo with messaging, but I'd like some answers in the
CQRS context.

Rinat Abdullin

unread,
Sep 5, 2010, 6:21:50 AM9/5/10
to ddd...@googlegroups.com
I'm storing domain-related metadata in message bodies. Sometimes
portions of these are copied to the message headers in order to
facilitate processing, routing and debugging. Or
infrastructure-specific fields might be added along:

* aggregateId;
* senderId;
* senderUrl;
* contractType;

In some cases message contains only metadata (i.e.: when Lokad.CQRS
message exceeds Azure Queue limit of a few Kb and has to be serialized
to Azure Blob instead).

While saving commands/events to logs (not the event store), this
information is saved along. This makes it simpler to debug problems
post-mortem, besides name of the contract is needed to deserialize
message body anyway.

A few more implementation details could be found here (specific to
Windows Azure and Lokad.CQRS):
http://code.google.com/p/lokad-cqrs/wiki/LokadMessageFormat

Best regards,
Rinat

Reply all
Reply to author
Forward
0 new messages