Task IMessageAuditStore.StoreMessage <T>(T message, MessageAuditMetadata metadata)
        {
            var auditRecord            = AuditRecord.Create(message, metadata, _partitionKeyFormatter);
            var insertOrMergeOperation = TableOperation.InsertOrMerge(auditRecord);

            return(_table.ExecuteAsync(insertOrMergeOperation));
        }
Exemplo n.º 2
0
        internal static AuditRecord Create <T>(T message, MessageAuditMetadata metadata, IPartitionKeyFormatter partitionKeyFormatter)
            where T : class
        {
            var record = new AuditRecord
            {
                RowKey             = $"{DateTime.MaxValue.Subtract(metadata.SentTime ?? DateTime.UtcNow).TotalMilliseconds}",
                ContextType        = metadata.ContextType,
                MessageId          = metadata.MessageId,
                ConversationId     = metadata.ConversationId,
                CorrelationId      = metadata.CorrelationId,
                InitiatorId        = metadata.InitiatorId,
                RequestId          = metadata.RequestId,
                SentTime           = metadata.SentTime,
                SourceAddress      = metadata.SourceAddress,
                InputAddress       = metadata.InputAddress,
                DestinationAddress = metadata.DestinationAddress,
                ResponseAddress    = metadata.ResponseAddress,
                FaultAddress       = metadata.FaultAddress,
                Headers            = JsonConvert.SerializeObject(metadata.Headers),
                Custom             = JsonConvert.SerializeObject(metadata.Custom),
                Message            = JsonConvert.SerializeObject(message),
                MessageType        = TypeMetadataCache <T> .ShortName
            };

            record.PartitionKey = SanitizePartitionKey(partitionKeyFormatter.Format <T>(record));

            return(record);
        }