private void CreateQueue(string queueName, QueueMeta meta)
        {
            var parameters = this.Meta.CreateGeneralParameters(CMQConstant.CreateQueue);

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

            if (meta.MaxMsgHeapNum > 0)
            {
                parameters.Add("maxMsgHeapNum", Convert.ToString(meta.MaxMsgHeapNum));
            }
            if (meta.PollingWaitSeconds > 0)
            {
                parameters.Add("pollingWaitSeconds", Convert.ToString(meta.PollingWaitSeconds));
            }
            if (meta.VisibilityTimeout > 0)
            {
                parameters.Add("visibilityTimeout", Convert.ToString(meta.VisibilityTimeout));
            }
            if (meta.MaxMsgSize > 0)
            {
                parameters.Add("maxMsgSize", Convert.ToString(meta.MaxMsgSize));
            }
            if (meta.MsgRetentionSeconds > 0)
            {
                parameters.Add("msgRetentionSeconds", Convert.ToString(meta.MsgRetentionSeconds));
            }

            var signature = Sign.Signature(parameters, this.Meta.Endpoint.Queue, this.Meta.Path, this.Meta.SecretKey, "POST", this.Meta.SignMethod);

            parameters.Add("Signature", signature);
            var result = string.Concat(this.Meta.Endpoint.Queue, this.Meta.Path)
                         .GetUriJsonContent <GeneralCMQBaseMessage>((http) =>
            {
                return(http.Wrap(parameters.CreateRequestBody()));
            });

            result.IfHasErrorThrowException();
            return;
        }
Exemple #2
0
        public void SetQueueAttributes(QueueMeta meta)
        {
            var parameters = this.ClientMeta.CreateGeneralParameters(CMQConstant.SetQueueAttributes);

            parameters.Add("queueName", this.QueueName);
            if (meta.MaxMsgHeapNum > 0)
            {
                parameters.Add("maxMsgHeapNum", Convert.ToString(meta.MaxMsgHeapNum));
            }
            if (meta.PollingWaitSeconds > 0)
            {
                parameters.Add("pollingWaitSeconds", Convert.ToString(meta.PollingWaitSeconds));
            }
            if (meta.VisibilityTimeout > 0)
            {
                parameters.Add("visibilityTimeout", Convert.ToString(meta.VisibilityTimeout));
            }
            if (meta.MaxMsgSize > 0)
            {
                parameters.Add("maxMsgSize", Convert.ToString(meta.MaxMsgSize));
            }
            if (meta.MsgRetentionSeconds > 0)
            {
                parameters.Add("msgRetentionSeconds", Convert.ToString(meta.MsgRetentionSeconds));
            }

            var signature = Sign.Signature(
                parameters,
                this.ClientMeta.Endpoint.Queue,
                this.ClientMeta.Path,
                this.ClientMeta.SecretKey, "POST", this.ClientMeta.SignMethod);

            parameters.Add("Signature", signature);
            var result = this.GenerateRequest()
                         .GetUriJsonContent <QueueMeta>((http) =>
            {
                return(http.Wrap(parameters.CreateRequestBody()));
            });
        }