[英]How to get Message count in Topic in WSO2 MB using AdminServices
為了從主題中獲取消息計數,我調用了WSO2 MB 3.1.0 AdminService api調用。 它適用於隊列,但不適用於該主題。 調用主題時,它沒有給出正確的計數(始終為0)
(為了在WSO2 MB管理控制台中的主題中顯示消息計數,我在WSO2 ESB中創建了具有掛起狀態的入站終結點,並為該主題創建了持久訂閱)
https://localhost:9447/services/AndesAdminService.AndesAdminServiceHttpsSoap12Endpoint
要求正文:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://wso2.org/carbon/andes/admin/xsd">
<soap:Header/>
<soap:Body>
<xsd:getMessageCount>
<!--Optional:-->
<xsd:destinationName>test-queue</xsd:destinationName>
<!--Optional:-->
<xsd:msgPattern>**queue**</xsd:msgPattern>
</xsd:getMessageCount>
</soap:Body>
</soap:Envelope>
網址: https://localhost:9447/services/AndesAdminService.AndesAdminServiceHttpsSoap12Endpoint
要求正文:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://wso2.org/carbon/andes/admin/xsd">
<soap:Header/>
<soap:Body>
<xsd:getMessageCount>
<!--Optional:-->
<xsd:destinationName>mytopic</xsd:destinationName>
<!--Optional:-->
<xsd:msgPattern>**topic**</xsd:msgPattern>
</xsd:getMessageCount>
</soap:Body>
</soap:Envelope>
我將messagePattern設置為“ topic”,以獲取該主題中的郵件數。 這不正確嗎? 如果是這樣,使用Admin服務在主題中獲取消息計數的正確方法是什么。
參考: https : //docs.wso2.com/display/MB310/Calling+Admin+Services+from+Apps
無法獲取主題的郵件計數。 主題應該是實時的,“主題”中的消息計數沒有意義。
但是,如果您正在尋找“耐用主題”中剩余的消息數,則可以傳遞以下信息並獲取消息數。
queuename = carbon:{subscription ID},msgPattern =隊列
相關代碼
public long getMessageCount(String queueName, String msgPattern) throws MBeanException {
if (log.isDebugEnabled()) {
log.debug("Counting at queue : " + queueName);
}
long messageCount = 0;
try {
if (!DLCQueueUtils.isDeadLetterQueue(queueName)) {
if ("queue".equals(msgPattern)) {
messageCount = Andes.getInstance().getMessageCountOfQueue(queueName);
}
} else {
messageCount = Andes.getInstance().getMessageCountInDLC(queueName);
}
} catch (AndesException e) {
log.error(MESSAGE_COUNT_RETRIEVE_ERROR + queueName, e);
throw new MBeanException(e, MESSAGE_COUNT_RETRIEVE_ERROR + queueName);
}
return messageCount;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.