Пример #1
0
        /// <summary>
        ///     Creates a service remoting client factory for connecting to the service over remoted service interfaces.
        /// </summary>
        /// <param name="callbackClient">
        ///     Client implementation where the callbacks should be dispatched.
        /// </param>
        /// <returns>
        ///     A <see cref="Microsoft.ServiceFabric.Services.Remoting.FabricTransport.Client.FabricTransportServiceRemotingClientFactory"/>
        ///     as <see cref="Microsoft.ServiceFabric.Services.Remoting.Client.IServiceRemotingClientFactory"/>
        ///     that can be used with <see cref="Microsoft.ServiceFabric.Services.Remoting.Client.ServiceProxyFactory"/> to
        ///     generate service proxy to talk to a stateless or stateful service over remoted actor interface.
        /// </returns>
        public override IServiceRemotingClientFactory CreateServiceRemotingClientFactory(
            IServiceRemotingCallbackClient callbackClient)
        {
            var settings = FabricTransportRemotingSettings.GetDefault();

            settings.MaxMessageSize   = this.GetAndValidateMaxMessageSize(settings.MaxMessageSize);
            settings.OperationTimeout = this.GetAndValidateOperationTimeout(settings.OperationTimeout);
            settings.KeepAliveTimeout = this.GetKeepAliveTimeout(settings.KeepAliveTimeout);
            settings.ConnectTimeout   = this.GetConnectTimeout(settings.ConnectTimeout);
            return(new FabricTransportServiceRemotingClientFactory(settings, callbackClient));
        }
Пример #2
0
        /// <summary>
        ///     Creates a  V2 service remoting client factory for connecting to the service over remoted service interfaces.
        /// </summary>
        /// <param name="callbackMessageHandler">
        ///    The client implementation where the callbacks should be dispatched.
        /// </param>
        /// <returns>
        ///     A <see cref="FabricTransportServiceRemotingClientFactory"/>
        ///     as <see cref="V2.Client.IServiceRemotingClientFactory"/>
        ///     that can be used with <see cref="Remoting.Client.ServiceProxyFactory"/> to
        ///     generate service proxy to talk to a stateless or stateful service over remoted actor interface.
        /// </returns>

        public override V2.Client.IServiceRemotingClientFactory CreateServiceRemotingClientFactoryV2(
            IServiceRemotingCallbackMessageHandler callbackMessageHandler)
        {
            var settings = FabricTransportRemotingSettings.GetDefault();

            settings.MaxMessageSize   = this.GetAndValidateMaxMessageSize(settings.MaxMessageSize);
            settings.OperationTimeout = this.GetAndValidateOperationTimeout(settings.OperationTimeout);
            settings.KeepAliveTimeout = this.GetKeepAliveTimeout(settings.KeepAliveTimeout);
            settings.ConnectTimeout   = this.GetConnectTimeout(settings.ConnectTimeout);
            return(new V2.FabricTransport.Client.FabricTransportServiceRemotingClientFactory(remotingSettings: settings,
                                                                                             remotingCallbackMessageHandler: callbackMessageHandler));
        }
Пример #3
0
        /// <summary>
        /// Try to load the FabricTransport settings from a sectionName specified in the configuration file.
        /// Configuration File can be specified using the filePath or using the name of the configuration package specified in the service manifest .
        /// It will first try to load config using configPackageName . if configPackageName is not specified then try to load  from filePath.
        /// </summary>
        /// <param name="sectionName">Name of the section within the configuration file. If not found section in configuration file, it return false</param>
        /// <param name="filepath"> Full path of the file where the settings will be loaded from.
        ///  If not specified , it will first try to load from default Config Package"Config" , if not found then load from Settings "ClientExeName.Settings.xml" present in Client Exe directory. </param>
        ///  <param name="configPackageName"> Name of the configuration package. If its null or empty,it will check for file in filePath</param>
        /// <param name="settings">When this method returns it sets the <see cref="FabricTransportRemotingSettings"/> settings if load from Config succeeded. If fails ,its sets settings to null/> </param>
        /// <returns><see cref="bool"/> specifies whether the settings get loaded successfully from Config.
        /// It returns true when load from Config succeeded, else return false. </returns>
        /// <remarks>
        /// The following are the parameter names that should be provided in the configuration file,to be recognizable by service fabric to load the transport settings.
        ///
        ///     1. MaxQueueSize - <see cref="MaxQueueSize"/>value in long.
        ///     2. MaxMessageSize - <see cref="MaxMessageSize"/>value in bytes.
        ///     3. MaxConcurrentCalls - <see cref="MaxConcurrentCalls"/>value in long.
        ///     4. SecurityCredentials - <see cref="SecurityCredentials"/> value.
        ///     5. OperationTimeoutInSeconds - <see cref="OperationTimeout"/> value in seconds.
        ///     6. KeepAliveTimeoutInSeconds - <see cref="KeepAliveTimeout"/> value in seconds.
        /// </remarks>
        public static bool TryLoadFrom(string sectionName, out FabricTransportRemotingSettings settings,
                                       string filepath          = null,
                                       string configPackageName = null)
        {
            FabricTransportSettings transportSettings;
            var isSucceded = FabricTransportSettings.TryLoadFrom(sectionName, out transportSettings, filepath,
                                                                 configPackageName);

            if (isSucceded)
            {
                settings = new FabricTransportRemotingSettings(transportSettings);
                return(true);
            }

            settings = null;
            return(isSucceded);
        }
        /// <summary>
        /// Returns the default Settings. Loads the configuration file from default Config Package"Config", if not found then try to load from  default config file "ClientExeName.Settings.xml"  from Client Exe directory.
        ///</summary>
        /// <param name="sectionName">The name of the section within the configuration file. If not found section in configuration file, it will return the default Settings.</param>
        /// <returns></returns>
        internal static FabricTransportRemotingSettings GetDefault(string sectionName = DefaultSectionName)
        {
            FabricTransportSettings transportSettings;

            transportSettings = FabricTransportSettings.GetDefault(sectionName);
            var settings = new FabricTransportRemotingSettings(transportSettings);

            AppTrace.TraceSource.WriteInfo(
                Tracetype,
                "MaxMessageSize: {0} , MaxConcurrentCalls: {1} , MaxQueueSize: {2} , OperationTimeoutInSeconds: {3} KeepAliveTimeoutInSeconds : {4} , SecurityCredentials {5} , HeaderBufferSize {6}," +
                "HeaderBufferCount {7}",
                settings.MaxMessageSize,
                settings.MaxConcurrentCalls,
                settings.MaxQueueSize,
                settings.OperationTimeout.TotalSeconds,
                settings.KeepAliveTimeout.TotalSeconds,
                settings.SecurityCredentials.CredentialType,
                settings.HeaderBufferSize,
                settings.HeaderMaxBufferCount);
            return(settings);
        }