Reputation: 317
I have a consumer with generic argument IEvent
. This type is a base interface for all messages, and child interfaces of IEvent
have some other properties. I'd like to have access to the raw message with all properties of nested types instead of only IEvent
scope. These properties can be seen through RMQ admin dashboard and I think there should be a way to put them out.
Upvotes: 1
Views: 2892
Reputation: 33258
You could use context.TryGetMessage<T>()
to request the specific type, which essentially attempts to deserialize the message into the specified type (as long as it is in the list of messageTypes serialized into the header).
Otherwise, you can use context.TryGetMessage<JToken>()
, and get the JToken
from JSON.NET, which can be used to navigate the message body.
Honestly, this isn't the best approach to properly handling events, etc., so I'd refer to the documentation to see how to properly consume the various message types (and let MassTransit do the hard work).
Upvotes: 4