Tencent CMQ Golang SDK
与腾讯云官方SDK接口保持一致
所有的API中都有test case,这里使用CreateQueue举例。
var secretId = "YourTencentSecretId"
var secretKey = "YourTencentSecretKey"
var endpointQueue = "https://cmq-queue-sh.api.qcloud.com"
var endpointQueueInner = "http://cmq-queue-sh.api.tencentyun.com"
// 创建队列
func Test_CreateQueue(t *testing.T) {
//创建账户
account := cmq_go.NewAccount(endpointQueue, secretId, secretKey)
//设置队列metadata
meta := cmq_go.QueueMeta{}
meta.PollingWaitSeconds = 10
meta.VisibilityTimeout = 10
meta.MaxMsgSize = 1048576
meta.MsgRetentionSeconds = 345600
//创建队列queue-test-001
err := account.CreateQueue("queue-test-001", meta)
if err != nil {
t.Errorf("queue-test-001 created failed, %v", err.Error())
return
}
t.Log("queue-test-001 created")
//创建队列queue-test-002
err = account.CreateQueue("queue-test-002", meta)
if err != nil {
t.Errorf("queue-test-002 created failed, %v", err.Error())
return
}
t.Log("queue-test-002 created")
}
测试单个方法
go test -v -test.run Test_CreateQueue
- CreateQueue
- ListQueue
- GetQueueAttributes
- SetQueueAttributes
- DeleteQueue
- SendMessage
- BatchSendMessage
- ReceiveMessage
- BatchReceiveMessage
- DeleteMessage
- BatchDeleteMessage
- CreateTopic
- SetTopicAttributes
- ListTopic
- GetTopicAttributes
- DeleteTopic
- PublishMessage
- BatchPublishMessage
- Subscribe
- ListSubscriptionByTopic
- SetSubscriptionAttributes
- GetSubscriptionAttributes
- Unsubscribe