本文整理汇总了C++中MessageQueue::getTopic方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageQueue::getTopic方法的具体用法?C++ MessageQueue::getTopic怎么用?C++ MessageQueue::getTopic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MessageQueue
的用法示例。
在下文中一共展示了MessageQueue::getTopic方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: truncateMessageQueueNotMyTopic
void RebalanceImpl::truncateMessageQueueNotMyTopic()
{
std::map<std::string, SubscriptionData> subTable = getSubscriptionInner();
std::map<MessageQueue, ProcessQueue*>::iterator it = m_processQueueTable.begin();
for ( ; it != m_processQueueTable.end(); it++)
{
MessageQueue mq = it->first;
std::map<std::string, SubscriptionData>::iterator itt = subTable.find(mq.getTopic());
if (itt == subTable.end())
{
ProcessQueue* pq = it->second;
if (pq != NULL)
{
pq->setDroped(true);
//TODO log.info("doRebalance, {}, truncateMessageQueueNotMyTopic remove unnecessary mq, {}",
// consumerGroup, mq);
}
std::map<MessageQueue, ProcessQueue*>::iterator ittmp = it;
it++;
m_processQueueTable.erase(ittmp);
}
else
{
it++;
}
}
}
示例2: updateProcessQueueTableInRebalance
bool RebalanceImpl::updateProcessQueueTableInRebalance(const std::string& topic, std::set<MessageQueue>& mqSet)
{
bool changed = false;
// 将多余的队列删除
std::map<MessageQueue, ProcessQueue*>::iterator it = m_processQueueTable.begin();
for ( ; it != m_processQueueTable.end();)
{
MessageQueue mq = it->first;
if (mq.getTopic() == topic)
{
std::set<MessageQueue>::iterator its = mqSet.find(mq);
if (its == mqSet.end())
{
changed = true;
ProcessQueue* pq = it->second;
if (pq != NULL)
{
pq->setDroped(true);
removeUnnecessaryMessageQueue(mq, *pq);
//TODO log.info("doRebalance, {}, remove unnecessary mq, {}",
// consumerGroup, mq);
}
std::map<MessageQueue, ProcessQueue*>::iterator ittmp = it;
it++;
m_processQueueTable.erase(ittmp);
}
else
{
it++;
}
}
else
{
it++;
}
}
// 增加新增的队列
std::list<PullRequest> pullRequestList;
std::set<MessageQueue>::iterator its = mqSet.begin();
for (; its != mqSet.end(); its++)
{
MessageQueue mq = *its;
std::map<MessageQueue, ProcessQueue*>::iterator itm = m_processQueueTable.find(mq);
if (itm == m_processQueueTable.end())
{
PullRequest pullRequest;
pullRequest.setConsumerGroup(m_consumerGroup);
pullRequest.setMessageQueue(new MessageQueue(mq.getTopic(),mq.getBrokerName(),mq.getQueueId()));
pullRequest.setProcessQueue(new ProcessQueue());
// 这个需要根据策略来设置
long long nextOffset = computePullFromWhere(mq);
if (nextOffset >= 0)
{
pullRequest.setNextOffset(nextOffset);
pullRequestList.push_back(pullRequest);
changed = true;
m_processQueueTable[mq] = pullRequest.getProcessQueue();
//TODO log.info("doRebalance, {}, add a new mq, {}", consumerGroup, mq);
}
else
{
// 等待此次Rebalance做重试
//TODO log.warn("doRebalance, {}, add new mq failed, {}", consumerGroup, mq);
}
}
}
dispatchPullRequest(pullRequestList);
return changed;
}