use of com.tencentcloudapi.tdmq.v20200217.models.DescribeCmqQueueDetailRequest in project cmq-java-sdk by tencentyun.
the class Queue method getQueueAttributes.
/**
* 获取队列属性
*
* @return 返回的队列属性参数
*/
public QueueMeta getQueueAttributes() {
QueueMeta meta = new QueueMeta();
try {
CmqConfig cmqConfig = client.getCmqConfig();
Credential cred = new Credential(cmqConfig.getSecretId(), cmqConfig.getSecretKey());
String endPoint = cmqConfig.getEndpoint();
String region = CMQTool.convertRegion(endPoint);
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint(cmqConfig.getManagerEndpoint());
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
TdmqClient client = new TdmqClient(cred, region, clientProfile);
DescribeCmqQueueDetailRequest req = new DescribeCmqQueueDetailRequest();
req.setQueueName(this.queueName);
DescribeCmqQueueDetailResponse resp = client.DescribeCmqQueueDetail(req);
CmqQueue cmqQueue = resp.getQueueDescribe();
meta.maxMsgHeapNum = cmqQueue.getMaxMsgHeapNum().intValue();
meta.pollingWaitSeconds = cmqQueue.getPollingWaitSeconds().intValue();
meta.visibilityTimeout = cmqQueue.getVisibilityTimeout().intValue();
meta.maxMsgSize = cmqQueue.getMaxMsgSize().intValue();
meta.msgRetentionSeconds = cmqQueue.getMsgRetentionSeconds().intValue();
meta.createTime = (int) (cmqQueue.getCreateTime() / 1000);
meta.lastModifyTime = (int) (cmqQueue.getLastModifyTime() / 1000);
meta.activeMsgNum = cmqQueue.getActiveMsgNum().intValue();
meta.inactiveMsgNum = cmqQueue.getInactiveMsgNum().intValue();
if (null != cmqQueue.getRewindMsgNum()) {
meta.rewindmsgNum = cmqQueue.getRewindMsgNum().intValue();
}
if (null != cmqQueue.getMinMsgTime()) {
meta.minMsgTime = cmqQueue.getMinMsgTime().intValue();
}
if (null != cmqQueue.getDelayMsgNum()) {
meta.delayMsgNum = cmqQueue.getDelayMsgNum().intValue();
}
meta.rewindSeconds = cmqQueue.getRewindSeconds().intValue();
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
}
return meta;
}
Aggregations