How to get the most concrete message in a general consumer

25 views
Skip to first unread message

Svein Dybvik

unread,
Sep 14, 2016, 6:00:32 AM9/14/16
to masstransit-discuss
We have a hierarchy of event interfaces which all adds some properties, and I want to have a consumer (EventConsumer) which subscribe to messages on the highest level (IEvent). The consumer's responsibility is to store all events in a database. This database will serve as a history of everything happened in our distributed system (like an event source).

The hierarchy is something like this and only ConcreteEventX messages are published on the bus: 
IEvent
IDataEvent
IConcreteEvent1
ConcreteEvent1
IDomainEvent
IConcreteEvent2
ConcreteEvent2

What is the best way to get a json serialized object of the entire message from the message context (e.g. ConcreteEvent1)?
How can I get the name of the most concrete type/interface (ConcreteEvent1/IConcreteEvent) so that I can later on construct the events from the database (there is a SupportedMessageTypes which may be of use)?
 
The EventConsumer does not know all ConcreteEventX types as we cannot be sure that the EventConsumer runs in a process where all types are known.
 

 
 
Reply all
Reply to author
Forward
0 new messages