Ejemplo n.º 1
0
        public RemoteExecutorClient(string hostname)
        {
            _executorServiceCallback = new RemoteExecutorCallback();
            var context = new InstanceContext(_executorServiceCallback);

            // TODO: Process more than this single Endpoint named "NetTcpBinding_IExecutorService".
            // What about InstanceContext. Do we need another one if more than one Endpoint is parameterized.
            // Will it be usefull to offer more than one endpoint?
            // -> It will be usefull. What about offering chooseable predefined Endpoints? Eg.: NamedPipe or TCP.
            // .) NamedPipe will be used for local Executors or for the "Send a message to the Executor" Service.
            // .) TCP will be used for Executors on other machines.
            var uri = new Uri("net.tcp://" + hostname + ":9000/RExServer");
            EndpointIdentity identity = EndpointIdentity.CreateSpnIdentity("RExTheMighty");
            _channelFactory = new DuplexChannelFactory<IRemoteExecutor>(
                context, new NetTcpBinding(), new EndpointAddress(uri, identity));

            _reconnectTimer = new System.Timers.Timer(ReconnectTimeout) {AutoReset = false}; // Wait after channel failure before reconnect.
            _reconnectTimer.Elapsed += (s, e) => 
            {
                try
                {
                    if (!_isConnected)
                    {
                        Connect();
                    }
                }
                catch (Exception ex)
                {
                    Log.Trace("Failed to reconnect: "+ ex.Message);
                }
            };

            _isConnected = false;
        }
Ejemplo n.º 2
0
        public RemoteExecutorClient(string hostname)
        {
            _executorServiceCallback = new RemoteExecutorCallback();
            var context = new InstanceContext(_executorServiceCallback);

            // TODO: Process more than this single Endpoint named "NetTcpBinding_IExecutorService".
            // What about InstanceContext. Do we need another one if more than one Endpoint is parameterized.
            // Will it be usefull to offer more than one endpoint?
            // -> It will be usefull. What about offering chooseable predefined Endpoints? Eg.: NamedPipe or TCP.
            // .) NamedPipe will be used for local Executors or for the "Send a message to the Executor" Service.
            // .) TCP will be used for Executors on other machines.
            var uri = new Uri("net.tcp://" + hostname + ":9000/RExServer");
            EndpointIdentity identity = EndpointIdentity.CreateSpnIdentity("RExTheMighty");

            _channelFactory = new DuplexChannelFactory <IRemoteExecutor>(
                context, new NetTcpBinding(), new EndpointAddress(uri, identity));

            _reconnectTimer = new System.Timers.Timer(ReconnectTimeout)
            {
                AutoReset = false
            };                                                                               // Wait after channel failure before reconnect.
            _reconnectTimer.Elapsed += (s, e) =>
            {
                try
                {
                    if (!_isConnected)
                    {
                        Connect();
                    }
                }
                catch (Exception ex)
                {
                    Log.Trace("Failed to reconnect: " + ex.Message);
                }
            };

            _isConnected = false;
        }