コード例 #1
0
        public static void Main(string[] args)
        {
            //1) 配置服务信息
            WorkerPoolConfig config = new WorkerPoolConfig();

            config.Service = "MyService";
            config.Mode    = WorkerConfig.MODE_LB;


            int threadCount = 2;

            Console.WriteLine("Pooled Workers({0}) Run...", threadCount);
            WorkerPool pool = new WorkerPool(config);

            //2)以指定的线程数运行服务处理业务逻辑代码
            pool.Run(threadCount, new MyServiceHandler());
        }
コード例 #2
0
ファイル: RpcService.cs プロジェクト: firememory/honglm-zbus
        public static void Main(string[] args)
        {
            //1) 配置服务信息
            WorkerPoolConfig config = new WorkerPoolConfig();

            config.Service = "MyRpc";
            config.Mode    = WorkerConfig.MODE_LB;
            config.Brokers = new string[] { "127.0.0.1:15555" }; //总线地址(多总线注册)


            //2)以指定的线程数运行RPC实例
            int threadCount = 2;

            Console.WriteLine("Pooled RPC({0}) Run...", threadCount);
            WorkerPool     pool    = new WorkerPool(config);
            ServiceHandler handler = new JsonServiceHandler(new MyService());

            pool.Run(threadCount, handler);
        }