static string GetMessageId(ReceiveContext context)
 {
     try
     {
         return(context.GetMessageId()?.ToString() ?? context.TransportHeaders.Get <string>(MessageHeaders.TransportMessageId));
     }
     catch (Exception)
     {
         return(default);
示例#2
0
        public RawJsonConsumeContext(JsonSerializer deserializer, ReceiveContext receiveContext, JToken messageToken)
            : base(receiveContext)
        {
            _messageToken = messageToken ?? new JObject();

            _deserializer = deserializer;
            _messageTypes = new Dictionary <Type, ConsumeContext>();

            MessageId     = receiveContext.GetMessageId();
            CorrelationId = receiveContext.GetCorrelationId();
            RequestId     = receiveContext.GetRequestId();
        }
示例#3
0
        protected async Task Move(ReceiveContext context, Action <InMemoryTransportMessage, IDictionary <string, object> > preSend)
        {
            var messageId = context.GetMessageId(NewId.NextGuid());

            var body = context.GetBody();

            var messageType = "Unknown";

            if (context.TryGetPayload(out InMemoryTransportMessage receivedMessage))
            {
                messageType = receivedMessage.MessageType;
            }

            var transportMessage = new InMemoryTransportMessage(messageId, body, context.ContentType?.MediaType, messageType);

            transportMessage.Headers.SetHostHeaders();

            preSend(transportMessage, transportMessage.Headers);

            await _exchange.Send(transportMessage, CancellationToken.None).ConfigureAwait(false);
        }