Exemple #1
0
        public AcceptMessageSessionForNamespaceAsyncResult(SbmpMessagingFactory messagingFactory, ReceiveMode receiveMode, int prefetchCount, CreateControlLinkSettings controlLinkSettings, TimeSpan serverWaitTime, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
        {
            this.MessagingFactory    = messagingFactory;
            this.controlLinkSettings = controlLinkSettings;
            this.receiveMode         = receiveMode;
            AcceptMessageSessionForNamespaceCommand acceptMessageSessionForNamespaceCommand = new AcceptMessageSessionForNamespaceCommand()
            {
                PrefetchCount    = prefetchCount,
                ReceiveMode      = receiveMode,
                Timeout          = serverWaitTime,
                OperationTimeout = timeout
            };
            AcceptMessageSessionForNamespaceCommand acceptMessageSessionForNamespaceCommand1 = acceptMessageSessionForNamespaceCommand;
            RequestInfo requestInfo = new RequestInfo()
            {
                ServerTimeout    = new TimeSpan?(acceptMessageSessionForNamespaceCommand1.Timeout),
                OperationTimeout = new TimeSpan?(acceptMessageSessionForNamespaceCommand1.OperationTimeout)
            };
            RequestInfo requestInfo1 = requestInfo;
            Message     message      = this.controlLinkSettings.MessageCreator.CreateWcfMessage("http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpConnection/AcceptMessageSessionForNamespace", acceptMessageSessionForNamespaceCommand1, null, this.MessagingFactory.RetryPolicy, null, requestInfo1);

            if (base.SyncContinue(this.MessagingFactory.Channel.BeginRequest(message, SbmpProtocolDefaults.BufferTimeout(timeout, this.MessagingFactory.GetSettings().EnableAdditionalClientTimeout), base.PrepareAsyncCompletion(AcceptMessageSessionForNamespaceAsyncResult.operationComplete), this)))
            {
                base.Complete(true);
            }
        }
        private void Initialize(bool useWebStream, bool useHttpsWebStream, IEnumerable <Uri> baseAddresses)
        {
            List <Uri> uris = new List <Uri>();

            foreach (Uri baseAddress in baseAddresses)
            {
                if (base.Address == null)
                {
                    base.Address = baseAddress;
                }
                UriBuilder uriBuilder = new UriBuilder(baseAddress);
                if (!this.Settings.GatewayMode && string.Compare(uriBuilder.Scheme, "sb", StringComparison.OrdinalIgnoreCase) != 0)
                {
                    ExceptionTrace exception        = Microsoft.ServiceBus.Messaging.FxTrace.Exception;
                    string         invalidUriScheme = Resources.InvalidUriScheme;
                    object[]       scheme           = new object[] { uriBuilder.Scheme, "sb" };
                    throw exception.AsError(new ArgumentException(Microsoft.ServiceBus.SR.GetString(invalidUriScheme, scheme)), null);
                }
                if (!useWebStream)
                {
                    uriBuilder.Scheme = SbmpProtocolDefaults.TransportUriScheme;
                }
                else
                {
                    uriBuilder.Scheme = "sb";
                    uriBuilder.Port   = (useHttpsWebStream ? RelayEnvironment.RelayHttpsPort : RelayEnvironment.RelayHttpPort);
                }
                if (!this.Settings.GatewayMode && uriBuilder.Port == -1)
                {
                    if (!useWebStream)
                    {
                        uriBuilder.Port = RelayEnvironment.RelayNmfPort;
                    }
                    else
                    {
                        uriBuilder.Port = (useHttpsWebStream ? RelayEnvironment.RelayHttpsPort : RelayEnvironment.RelayHttpPort);
                    }
                }
                MessagingUtilities.EnsureTrailingSlash(uriBuilder);
                uris.Add(uriBuilder.Uri);
            }
            this.baseAddresses = null;
            this.BaseAddress   = uris.First <Uri>();
            bool          useSslStreamSecurity = this.Settings.UseSslStreamSecurity;
            CustomBinding customBinding        = SbmpProtocolDefaults.CreateBinding(false, useWebStream, useHttpsWebStream, 2147483647, useSslStreamSecurity, this.Settings.EndpointIdentity);
            DuplexRequestBindingElement duplexRequestBindingElement = new DuplexRequestBindingElement()
            {
                ClientMode = !this.Settings.GatewayMode,
                IncludeExceptionDetails = true
            };
            DuplexRequestBindingElement duplexRequestBindingElement1 = duplexRequestBindingElement;
            int num = 0;

            if (!this.Settings.GatewayMode)
            {
                RedirectBindingElement redirectBindingElement = new RedirectBindingElement()
                {
                    EnableRedirect          = this.Settings.EnableRedirect,
                    UseSslStreamSecurity    = useSslStreamSecurity,
                    IncludeExceptionDetails = true,
                    EndpointIdentity        = this.Settings.EndpointIdentity
                };
                RedirectBindingElement redirectBindingElement1 = redirectBindingElement;
                int num1 = num;
                num = num1 + 1;
                customBinding.Elements.Insert(num1, new ReconnectBindingElement(uris));
                int num2 = num;
                num = num2 + 1;
                customBinding.Elements.Insert(num2, redirectBindingElement1);
            }
            int num3 = num;

            num = num3 + 1;
            customBinding.Elements.Insert(num3, new ReconnectBindingElement(uris));
            int num4 = num;

            num = num4 + 1;
            customBinding.Elements.Insert(num4, duplexRequestBindingElement1);
            BindingParameterCollection bindingParameterCollection = new BindingParameterCollection();

            if (useSslStreamSecurity)
            {
                ClientCredentials clientCredential = new ClientCredentials();
                clientCredential.ServiceCertificate.Authentication.CertificateValidationMode  = X509CertificateValidationMode.Custom;
                clientCredential.ServiceCertificate.Authentication.CustomCertificateValidator = RetriableCertificateValidator.Instance;
                bindingParameterCollection.Add(clientCredential);
            }
            this.ChannelFactory  = customBinding.BuildChannelFactory <IRequestSessionChannel>(bindingParameterCollection);
            this.MessageVersion  = customBinding.MessageVersion;
            this.ResourceManager = SbmpResourceManager.Instance;
            this.acceptMessageSessionForNamespaceLinkSettings = new CreateControlLinkSettings(this, string.Empty, "||", MessagingEntityType.Namespace, null);
            EventHandler eventHandler = new EventHandler(this.OnInnerFactoryFaulted);

            this.ChannelFactory.SafeAddFaulted(eventHandler);
        }
        private SbmpMessageCreator InitializeControlLink()
        {
            CreateControlLinkSettings createControlLinkSetting = new CreateControlLinkSettings((SbmpMessagingFactory)base.MessagingFactory, base.SubscriptionPath, base.Name, MessagingEntityType.Subscriber, null);

            return(createControlLinkSetting.MessageCreator);
        }
        private SbmpMessageCreator InitializeControlLink()
        {
            CreateControlLinkSettings createControlLinkSetting = new CreateControlLinkSettings((SbmpMessagingFactory)base.MessagingFactory, base.Path, base.Path, MessagingEntityType.Queue, null);

            return(createControlLinkSetting.MessageCreator);
        }