예제 #1
0
        void SetReplyToAddress(OutgoingMessage outgoingMessage, BrokeredMessage brokeredMessage, RuntimeNamespaceInfo destinationNamespace)
        {
            if (outgoingMessage.Headers.ContainsKey(Headers.ReplyToAddress))
            {
                var replyToAddress = outgoingMessage.Headers[Headers.ReplyToAddress];
                // Read-only endpoints have no reply-to value
                if (string.IsNullOrWhiteSpace(replyToAddress))
                {
                    return;
                }

                var replyTo = new EntityAddress(replyToAddress);

                if (!replyTo.HasSuffix)
                {
                    var selected = SelectMostAppropriateReplyToNamespace(destinationNamespace);

                    if (selected != null)
                    {
                        if (useAliases)
                        {
                            replyTo = new EntityAddress(replyTo.Name, selected.Alias);
                        }
                        else
                        {
                            replyTo = new EntityAddress(replyTo.Name, selected.Connection);
                        }
                    }
                }

                var replyToAsString = replyTo.ToString();
                brokeredMessage.ReplyTo = replyToAsString;
            }
        }
        public virtual EntityAddress Map(EntityAddress value)
        {
            if (!value.HasConnectionString)
            {
                return(value);
            }

            var namespaceInfo = namespaces.SingleOrDefault(x => x.Connection == value.Suffix);

            if (namespaceInfo != null)
            {
                return(new EntityAddress($"{value.Name}@{namespaceInfo.Alias}"));
            }

            var namespaceName = new ConnectionStringInternal(value.Suffix).NamespaceName;

            logger.Warn($"Connection string for for namespace name '{namespaceName}' hasn't been configured. {Environment.NewLine}, replying may not work properly" +
                        "Use `AddNamespace` configuration API to map connection string to namespace alias.");
            return(value);
        }