コード例 #1
0
        public static void ForwardUsingOriginalContext(this ISendContext target,
                                                       IConsumeContext source)
        {
            target.SetRequestId(source.RequestId);
            target.SetConversationId(source.ConversationId);
            target.SetCorrelationId(source.CorrelationId);
            target.SetSourceAddress(source.SourceAddress);
            target.SetResponseAddress(source.ResponseAddress);
            target.SetFaultAddress(source.FaultAddress);
            target.SetNetwork(source.Network);
            if (source.ExpirationTime.HasValue)
            {
                target.SetExpirationTime(source.ExpirationTime.Value);
            }
            target.SetRetryCount(source.RetryCount);

            foreach (var header in source.Headers)
            {
                target.SetHeader(header.Key, header.Value);
            }

            var inputAddress = source.InputAddress != null
                                   ? source.InputAddress.ToString()
                                   : source.DestinationAddress != null
                                         ? source.DestinationAddress.ToString()
                                         : null;

            if (!string.IsNullOrEmpty(inputAddress))
            {
                target.SetHeader("mt.forwarder.uri", source.DestinationAddress.ToString());
            }
        }
コード例 #2
0
        public void PreDispatch(ISendContext context)
        {
            if (!string.IsNullOrEmpty(context.Headers[Constants.TenantIdKey]))
            {
                return;
            }

            object tenantId;

            if (_identificationStrategy.TryIdentifyTenant(out tenantId))
            {
                context.SetHeader(Constants.TenantIdKey, tenantId.ToString());
            }
        }
コード例 #3
0
        public static void ForwardUsingOriginalContext<T>(this ISendContext target,
            IConsumeContext<T> source)
            where T : class
        {
            target.SetRequestId(source.RequestId);
            target.SetConversationId(source.ConversationId);
            target.SetCorrelationId(source.CorrelationId);
            target.SetResponseAddress(source.ResponseAddress);
            target.SetFaultAddress(source.FaultAddress);
            target.SetNetwork(source.Network);
            if (source.ExpirationTime.HasValue)
                target.SetExpirationTime(source.ExpirationTime.Value);
            target.SetRetryCount(source.RetryCount);

            foreach (var header in source.Headers)
            {
                target.SetHeader(header.Key, header.Value);
            }
        }
コード例 #4
0
 private void PersistMessageSentTime(ISendContext sendContext, DateTimeOffset sentTime)
 {
     sendContext.SetHeader(MessageSentKey, sentTime.ToString("O"));
 }
コード例 #5
0
 private void PersistCorrelationId(ISendContext sendContext, Guid correlationId)
 {
     sendContext.SetHeader(CorrelationIdKey, correlationId.ToString("D"));
 }