Ejemplo n.º 1
0
        public static MyRpcClient Current(IModel channel, string queueName)
        {
            if (null == _myRpcClient)
            {
                _myRpcClient = new MyRpcClient(channel, queueName);
            }

            return(_myRpcClient);
        }
Ejemplo n.º 2
0
        public void Call(string queue)
        {
            if (string.IsNullOrWhiteSpace(queue))
            {
                return;
            }

            //这里必须上锁,否则在多线程环境下回报“Pipelining of requests forbidden”异常
            lock (lok)
            {
                IModel channel = GetRpcClientByQueue(queue);
                {
                    IBasicProperties replyProp;
                    IBasicProperties prop = channel.CreateBasicProperties();
                    prop.ContentEncoding = "UTF-8";
                    MyRpcClient.Current(new MyRpcClient(channel, queue).Call(prop, Encoding.UTF8.GetBytes("test"), out replyProp));
                }
            }
        }