Exemple #1
0
        public static void Main(string[] args)
        {
            //1) 配置RPC链接
            RpcConfig config = new RpcConfig();

            config.Service = "MyRpc";
            Rpc rpc = new Rpc(config);


            //2) 远程方法调用
            object res = rpc.Invoke("user", "前海股权交易中心");
            IDictionary <string, object> user = (Dictionary <string, object>)res;

            Console.WriteLine("name: " + user["name"]);
            Console.WriteLine("addr: " + user["addr"]);

            //3) 销毁链接
            rpc.Dispose();
            Console.ReadKey();
        }
Exemple #2
0
        public static void Main(string[] args)
        {
            SingleBrokerConfig brokerConfig = new SingleBrokerConfig();

            brokerConfig.brokerAddress = "127.0.0.1:15555";
            Broker broker = new SingleBroker(brokerConfig);

            RpcConfig config = new RpcConfig();

            config.mq     = "MyRpc";
            config.broker = broker;

            Rpc rpc = new Rpc(config);

            for (int i = 0; i < 100; i++)
            {
                object res = rpc.Invoke("stringArray");
                System.Console.WriteLine(res);
            }
            broker.Dispose();

            System.Console.ReadKey();
        }