Hello,
Background
We are building a series of new services (each in their own solutions). We also have an Audit Service in its own solution. The Audit service currently handles a base class message (that all messages across all of our services extend from). The Audit Service takes a copy of most messages and stores the body and some metadata in Table Storage for a limited time. We use this data as an Audit, also for debugging and to assert our integration tests have passed.
Currently, the Audit service must reference a series of internal nuget packages that contain our various message types from the different services in their separate solutions.
Issue
The requirement to reference the latest nuget references means the Audit service can get out of sync. This happens during local development before any message nuget package changes have been committed to nuget. As a result our integration tests can fail when running them locally.
Question
The Audit service doesn’t actually need to deserialize each message it handles to its inherited type, we are only interested in the meta data and the payload - but as a json/string. So it feels like we should be able to achieve what we need without most of the nuget references.
I was wondering if there is a way for me to intercept the audit sending process and transform the outgoing message into a standard MessageEnvelope type message that might look something like this:
public class MessageEnvelope
{
public Guid CorrelationId {get;set;}
public string OriginalPayload {get;set;}
public string OriginalMessageType{get;set;}
public DateTime OriginalMessageSentOn{get;set;}
//some other meta data from original message headers
}
Then in the Audit Service just have a single nuget reference to the Envelope (that would be a very stable package)
public class MessageEnvelopeHandler : IHandleMessages<MessageEnvelope>
{
public async Task Handle(MessageEnvelope message)
{
// write payload string and some meta data to table storage
}
}
I am also wondering if this is a bad idea!, and there is a better way to solve the problem.
Thanks for your help