示例#1
0
        public QueueMeta getQueueAttributes()
        {
            SortedDictionary <string, string> param = new SortedDictionary <string, string>();

            param.Add("queueName", this.queueName);

            string  result = this.client.call("GetQueueAttributes", param);
            JObject jObj   = JObject.Parse(result);
            int     code   = (int)jObj["code"];

            if (code != 0)
            {
                throw new ServerException(code, jObj["message"].ToString(), jObj["requestId"].ToString());
            }
            QueueMeta meta = new QueueMeta();

            meta.maxMsgHeapNum       = (int)jObj["maxMsgHeapNum"];
            meta.pollingWaitSeconds  = (int)jObj["pollingWaitSeconds"];
            meta.visibilityTimeout   = (int)jObj["visibilityTimeout"];
            meta.maxMsgSize          = (int)jObj["maxMsgSize"];
            meta.msgRetentionSeconds = (int)jObj["msgRetentionSeconds"];
            meta.createTime          = (int)jObj["createTime"];
            meta.lastModifyTime      = (int)jObj["lastModifyTime"];
            meta.activeMsgNum        = (int)jObj["activeMsgNum"];
            meta.inactiveMsgNum      = (int)jObj["inactiveMsgNum"];
            meta.rewindmsgNum        = (int)jObj["rewindMsgNum"];
            meta.minMsgTime          = (int)jObj["minMsgTime"];
            meta.delayMsgNum         = (int)jObj["delayMsgNum"];

            return(meta);
        }
示例#2
0
        public void createQueue(string queueName, QueueMeta meta)
        {
            SortedDictionary <string, string> param = new SortedDictionary <string, string>();

            if (queueName == "")
            {
                throw new ClientException("Invalid parameter: queueName is empty");
            }
            else
            {
                param.Add("queueName", queueName);
            }

            if (meta.maxMsgHeapNum > 0)
            {
                param.Add("maxMsgHeapNum", Convert.ToString(meta.maxMsgHeapNum));
            }
            if (meta.pollingWaitSeconds > 0)
            {
                param.Add("pollingWaitSeconds", Convert.ToString(meta.pollingWaitSeconds));
            }
            if (meta.visibilityTimeout > 0)
            {
                param.Add("visibilityTimeout", Convert.ToString(meta.visibilityTimeout));
            }
            if (meta.maxMsgSize > 0)
            {
                param.Add("maxMsgSize", Convert.ToString(meta.maxMsgSize));
            }
            if (meta.msgRetentionSeconds > 0)
            {
                param.Add("msgRetentionSeconds", Convert.ToString(meta.msgRetentionSeconds));
            }

            string  result = this.client.call("CreateQueue", param);
            JObject jObj   = JObject.Parse(result);
            int     code   = (int)jObj["code"];

            if (code != 0)
            {
                throw new ServerException(code, jObj["message"].ToString(), jObj["requestId"].ToString());
            }
            return;
        }
示例#3
0
        public void setQueueAttributes(QueueMeta meta)
        {
            SortedDictionary <string, string> param = new SortedDictionary <string, string>();

            param.Add("queueName", this.queueName);
            if (meta.maxMsgHeapNum > 0)
            {
                param.Add("maxMsgHeapNum", Convert.ToString(meta.maxMsgHeapNum));
            }
            if (meta.pollingWaitSeconds > 0)
            {
                param.Add("pollingWaitSeconds", Convert.ToString(meta.pollingWaitSeconds));
            }
            if (meta.visibilityTimeout > 0)
            {
                param.Add("visibilityTimeout", Convert.ToString(meta.visibilityTimeout));
            }
            if (meta.maxMsgSize > 0)
            {
                param.Add("maxMsgSize", Convert.ToString(meta.maxMsgSize));
            }
            if (meta.msgRetentionSeconds > 0)
            {
                param.Add("msgRetentionSeconds", Convert.ToString(meta.msgRetentionSeconds));
            }

            string  result = this.client.call("SetQueueAttributes", param);
            JObject jObj   = JObject.Parse(result);
            int     code   = (int)jObj["code"];

            if (code != 0)
            {
                throw new ServerException(code, jObj["message"].ToString(), jObj["requestId"].ToString());
            }
            return;
        }