static void Main(string[] args) { string secretId = ""; string secretKey = ""; string endpoint = "http://cmq-queue-gz.api.qcloud.com"; string path = "/v2/index.php"; Account account = new Account(secretId, secretKey, endpoint, path); QueueMeta meta = new QueueMeta(); //创建队列 account.CreateQueue("q11", meta); CMQClient cMQClient = new CMQClient(endpoint, path, secretId, secretKey, "POST"); Queue queue = new Queue("q11", cMQClient); var msgId = queue.SendMessage("ceshi message"); //消费一条消息 var resReceive = queue.ReceiveMessage(30); //删除消息 queue.DeleteMessage(resReceive.ReceiptHandle); //获取队列列数 List <QueueInfo> list = new List <QueueInfo>(); var count = account.ListQueue("", 1, 1, list); Topic topic = new Topic("topc1", cMQClient); topic.PublishMessage("messsssss"); Subscription subscription = new Subscription("topc1", "subscription1", cMQClient); subscription.GetSubscriptionAttributes(); Console.WriteLine("Hello World!"); }
/** * construct . * * @param topicName String * @param client CMQClient */ internal Topic(string topicName, CMQClient client) { this.topicName = topicName; this.client = client; }
/// <summary> /// 订阅 /// </summary> /// <param name="topicName">主题名字,在单个地域同一帐号下唯一。主题名称是一个不超过 64 个字符的字符串,必须以字母为首字符,剩余部分可以包含字母、数字和横划线(-)。</param> /// <param name="subscriptionName">订阅名字,在单个地域同一帐号的同一主题下唯一。订阅名称是一个不超过 64 个字符的字符串,必须以字母为首字符,剩余部分可以包含字母、数字和横划线(-)。</param> /// <param name="client"></param> internal Subscription(String topicName, String subscriptionName, CMQClient client) { this.topicName = topicName; this.subscriptionName = subscriptionName; this.client = client; }
/// <summary> /// 构造函数 /// </summary> /// <param name="secretId">密钥Id</param> /// <param name="secretKey">密钥Key</param> /// <param name="endpoint">请求域名,例如:广州访问点->http://cmq-queue-gz.api.tencentyun.com</param> /// <param name="path">例如:/v2/index.php</param> /// <param name="method">POST/GET,默认为POST</param> public Account(string secretId, string secretKey, string endpoint = "http://cmq-queue-gz.api.tencentyun.com", string path = "/v2/index.php", string method = "POST") { this.client = new CMQClient(endpoint, path, secretId, secretKey, method); }
/// <summary> /// 构造函数 /// </summary> /// <param name="queueName"></param> /// <param name="client"></param> internal Queue(string queueName, CMQClient client) { this.queueName = queueName; this.client = client; }