Exemplo n.º 1
0
 public IMessageContext WrapMessage(object message,
                                    string correlationId = null,
                                    string topic         = null,
                                    string key           = null,
                                    string replyEndPoint = null,
                                    string messageId     = null,
                                    SagaInfo sagaInfo    = null,
                                    string producer      = null)
 {
     return(_clientProvider.WrapMessage(message,
                                        correlationId,
                                        topic,
                                        key,
                                        replyEndPoint,
                                        messageId,
                                        sagaInfo,
                                        producer));
 }
Exemplo n.º 2
0
        public IMessageContext WrapMessage(object message,
                                           string correlationId = null,
                                           string topic         = null,
                                           string key           = null,
                                           string replyEndPoint = null,
                                           string messageId     = null,
                                           SagaInfo sagaInfo    = null,
                                           string producer      = null)
        {
            if (message is Exception ex)
            {
                if (ex is DomainException domainException)
                {
                    // Remove inner Exception because it too large after serializing
                    message = new DomainException(domainException.ErrorCode, domainException.Message);
                }
                else
                {
                    message = new Exception(ex.GetBaseException().Message);
                }
            }
            var messageContext = _clientProvider.WrapMessage(message,
                                                             correlationId,
                                                             topic,
                                                             key,
                                                             replyEndPoint,
                                                             messageId,
                                                             sagaInfo,
                                                             producer);

            if (string.IsNullOrWhiteSpace(messageContext.Key))
            {
                messageContext.Key = messageContext.MessageId;
            }

            return(messageContext);
        }