添加错误映射文件的处理防止崩溃,优化mq处理topic前缀,添加空指针预防
This commit is contained in:
@@ -267,6 +267,23 @@ void RocketMQConsumer::subscribe(const std::string& topic, const std::string& ta
|
||||
// 使用 std::pair 作为键
|
||||
std::pair<std::string, std::string> mapKey(topic, tag);
|
||||
callbacks_[mapKey] = callback;
|
||||
|
||||
//冀北添加,其他地方也通用
|
||||
// 如果带 MQ_INST_xxx% 前缀,再注册一个短topic
|
||||
size_t pos = topic.find('%');
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
std::string shortTopic = topic.substr(pos + 1);
|
||||
|
||||
callbacks_[std::make_pair(shortTopic, tag)] = callback;
|
||||
|
||||
std::cout << "[CALLBACK_ALIAS] "
|
||||
<< topic
|
||||
<< " -> "
|
||||
<< shortTopic
|
||||
<< ", tag=" << tag
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
/*
|
||||
// 静态消息处理回调实现
|
||||
@@ -513,6 +530,8 @@ public:
|
||||
//SetProducerMaxMessageSize(producer_, 1024 * 1024); // 1MB
|
||||
producer_.setMaxMessageSize(1024 * 1024);
|
||||
|
||||
producer_.setSendMsgTimeout(3000);//添加超时防阻塞
|
||||
|
||||
//SetProducerSessionCredentials(producer_, G_MQCONSUMER_ACCESSKEY.c_str(),G_MQCONSUMER_SECRETKEY.c_str(), "");
|
||||
producer_.setSessionCredentials(
|
||||
G_MQCONSUMER_ACCESSKEY,
|
||||
|
||||
Reference in New Issue
Block a user