修改mq为C++库并固定生产者和消费者

This commit is contained in:
lnk
2026-04-28 11:44:40 +08:00
parent b87da0f454
commit b1d8440e6a
9 changed files with 636 additions and 225 deletions

View File

@@ -7167,6 +7167,7 @@ void send_reply_to_kafka(const std::string& guid, const std::string& step, const
// 封装 Kafka 消息
Ckafka_data_t connect_info;
connect_info.strTopic = QString::fromStdString(Topic_Reply_Topic);
connect_info.mp_id = QString::fromStdString(guid);//guid作为key
connect_info.strText = QString::fromStdString(jsonString);
// 加入发送队列(带互斥锁保护)
@@ -7195,6 +7196,7 @@ void send_reply_to_kafka_recall(const std::string& guid, const std::string& step
// 封装 Kafka 消息
Ckafka_data_t connect_info;
connect_info.strTopic = QString::fromStdString(Topic_Reply_Topic);
connect_info.mp_id = QString::fromStdString(guid);//guid作为key
connect_info.strText = QString::fromStdString(jsonString);
// 加入发送队列(带互斥锁保护)
@@ -7204,20 +7206,25 @@ void send_reply_to_kafka_recall(const std::string& guid, const std::string& step
}
void send_heartbeat_to_kafka(const std::string& status) {
std::string front_type = get_front_type_from_subdir();
// 构造 JSON 字符串
std::ostringstream oss;
oss << "{"
<< "\"nodeId\":\"" << FRONT_INST << "\","
<< "\"frontType\":\"" << get_front_type_from_subdir() << "\","
<< "\"frontType\":\"" << front_type << "\","
<< "\"processNo\":\"" << g_front_seg_index << "\","
<< "\"status\":\"" << status << "\""
<< "}";
std::string jsonString = oss.str();
std::string mpid_str = std::to_string(g_node_id) + "_" + std::to_string(g_front_seg_index);
// 封装 Kafka 消息
Ckafka_data_t connect_info;
connect_info.strTopic = QString::fromStdString(Heart_Beat_Topic);
connect_info.mp_id = QString::fromStdString(mpid_str);
connect_info.strText = QString::fromStdString(jsonString);
// 加入发送队列(带互斥锁保护)