当前位置: 首页>>代码示例>>C++>>正文


C++ Message_ptr::getTopic方法代码示例

本文整理汇总了C++中Message_ptr::getTopic方法的典型用法代码示例。如果您正苦于以下问题:C++ Message_ptr::getTopic方法的具体用法?C++ Message_ptr::getTopic怎么用?C++ Message_ptr::getTopic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Message_ptr的用法示例。


在下文中一共展示了Message_ptr::getTopic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sendKernelImpl

SendResult_ptr DefaultMQProducerImpl::sendKernelImpl(Message_ptr msg, MessageQueue* mq, std::string& communicationMode, bool sendCallback) {
    std::string brokerAddr = this->mQClientFactory->findBrokerAddressInPublish(mq->getBrokerName());
    if (brokerAddr.empty()) {
        // TODO 此处可能对Name Server压力过大,需要调优
        this->mQClientFactory->updateTopicRouteInfoFromNameServer(mq->getTopic());
        this->mQClientFactory->updateTopicRouteInfoFromNameServer(mq->getTopic(), true, this->defaultMQProducer);
        brokerAddr = this->mQClientFactory->findBrokerAddressInPublish(mq->getBrokerName());
    }

    if (!brokerAddr.empty()) {
        std::string prevBody = msg->getBody();
        int sysFlag = 0;

        SendMessageRequestHeader_var requestHeader = new SendMessageRequestHeader();
        requestHeader->setProducerGroup(this->defaultMQProducer->getProducerGroup());
        requestHeader->setTopic(msg->getTopic());
        requestHeader->setDefaultTopic(this->defaultMQProducer->getCreateTopicKey());
        requestHeader->setDefaultTopicQueueNums(this->defaultMQProducer->getDefaultTopicQueueNums());
        requestHeader->setQueueId(mq->getQueueId());
        requestHeader->setSysFlag(sysFlag);
        requestHeader->setBornTimestamp(112233);
        requestHeader->setFlag(msg->getFlag());

        SendResult_var sendResult = new SendResult();
        this->mQClientFactory->getMQClientAPIImpl()->sendMessage(brokerAddr, mq->getBrokerName(), SendMessageRequestHeader_var::Duplicate(requestHeader), 3);
        return SendResult_var::Duplicate(sendResult);
    }
    return NULL;
}
开发者ID:Warren5382,项目名称:remotingclient,代码行数:29,代码来源:defaultmqproducerimpl.cpp

示例2: sendDefaultImpl

SendResult_ptr DefaultMQProducerImpl::sendDefaultImpl(Message_ptr msg, std::string& communicationMode, bool sendCallback) {
    long beginTimestamp = 0;
    long endTimestamp = beginTimestamp;
    TopicPublishInfo* topicPublishInfo = this->tryToFindTopicPublishInfo(msg->getTopic());
    if (topicPublishInfo->ok()) {
        MessageQueue* mq = NULL;
        SendResult_var sendResult = new SendResult();
        for (int times = 0; times < 3; times++) {
            std::string lastBrokerName;
            if(mq != NULL) {
                lastBrokerName = mq->getBrokerName();
            }
            MessageQueue* tmpmq = topicPublishInfo->selectOneMessageQueue(lastBrokerName);
            if (tmpmq != NULL) {
                mq = tmpmq;
                sendResult = this->sendKernelImpl(msg, mq, communicationMode, sendCallback);
                endTimestamp = 12;
                if(communicationMode == CommunicationMode::SYNC) {
                    if (sendResult->getSendStatus() != SendStatus::SEND_OK) {
                        /*
                        if (this->defaultMQProducer->isRetryAnotherBrokerWhenNotStoreOK()) {
                        	continue;
                        }
                        */
                    }
                    return SendResult_var::Duplicate(sendResult);
                }
            }
            else {
                break;
            }
        }
        return SendResult_var::Duplicate(sendResult);
    }
    return NULL;
}
开发者ID:Warren5382,项目名称:remotingclient,代码行数:36,代码来源:defaultmqproducerimpl.cpp


注:本文中的Message_ptr::getTopic方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。