[英]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.