简体   繁体   English

如何使用AdminServices在WSO2 MB中的主题中获取消息计数

[英]How to get Message count in Topic in WSO2 MB using AdminServices

To get the message count from topic, I have invoked the WSO2 MB 3.1.0 AdminService api calls. 为了从主题中获取消息计数,我调用了WSO2 MB 3.1.0 AdminService api调用。 It worked for queue but not for the topic. 它适用于队列,但不适用于该主题。 When invoking with topic, it doesn't give the correct count (it always gives 0) 调用主题时,它没有给出正确的计数(始终为0)
(To show the message count in topic in WSO2 MB Management console, I have created an inbound endpoint with suspend state in WSO2 ESB and created a durable subscription to the topic) (为了在WSO2 MB管理控制台中的主题中显示消息计数,我在WSO2 ESB中创建了具有挂起状态的入站终结点,并为该主题创建了持久订阅)

  1. Get Message Count from queue. 从队列获取消息计数。
    url: https://localhost:9447/services/AndesAdminService.AndesAdminServiceHttpsSoap12Endpoint 网址: https://localhost:9447/services/AndesAdminService.AndesAdminServiceHttpsSoap12Endpoint

Request body: 要求正文:

<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>
  1. Get Message Count from topic. 从主题获取消息计数。

url: https://localhost:9447/services/AndesAdminService.AndesAdminServiceHttpsSoap12Endpoint 网址: https://localhost:9447/services/AndesAdminService.AndesAdminServiceHttpsSoap12Endpoint

Request body: 要求正文:

<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>

I set the messagePattern as "topic" to get the message count in the topic. 我将messagePattern设置为“ topic”,以获取该主题中的邮件数。 Is this not correct? 这不正确吗? If so whats the correct way of getting the message count in a topic using Admin services. 如果是这样,使用Admin服务在主题中获取消息计数的正确方法是什么。

Reference: https://docs.wso2.com/display/MB310/Calling+Admin+Services+from+Apps 参考: https : //docs.wso2.com/display/MB310/Calling+Admin+Services+from+Apps

There is no way to get message count of topics. 无法获取主题的邮件计数。 Topics are supposed to be real time and there is no meaning to a message count in a "topic". 主题应该是实时的,“主题”中的消息计数没有意义。

However, if you are looking for a message count remaining in a "durable topic", you can pass below information and get the message count. 但是,如果您正在寻找“耐用主题”中剩余的消息数,则可以传递以下信息并获取消息数。

queuename = carbon:{subscription ID} , msgPattern = queue queuename = carbon:{subscription ID},msgPattern =队列

Relevant code 相关代码

   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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM