Exemplo n.º 1
0
        static void InitProxyService()
        {
            var containerBuilder = new ContainerBuilder();
            var host             = new Jimu.Client.ApplicationClientBuilder(containerBuilder)
                                   //.UseLog4netLogger(new LogOptions { EnableConsoleLog = true })
                                   //.UsePollingAddressSelector()
                                   //.UseConsulForDiscovery(new Jimu.Client.Discovery.ConsulIntegration.ConsulOptions("127.0.0.1", 8500, "JimuService-"))
                                   //.UseDotNettyForTransfer()
                                   //.UseHttpForTransfer()
                                   //.UseServiceProxy(new Jimu.Client.Proxy.ServiceProxyOptions(new[] { "IServices" }))
                                   .Build()
            ;

            host.Run();
            var proxy = host.Container.Resolve <IServiceProxy>();

            _echoService = proxy.GetService <IEchoService>();
            Task.Run(() =>
            {
                Thread.Sleep(5000);
                var ret = _echoService.GetEcho("哈哈");
                Console.WriteLine("==== echo " + ret);
            });
        }