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

@@ -45,6 +45,8 @@ extern std::string WEB_EVENT;
extern std::string WEB_FILEDOWNLOAD;
extern std::string G_CONNECT_TOPIC;
extern int RECALL_ONLY_FLAG;
//lnk20250115添加台账锁
extern pthread_mutex_t mtx;
@@ -3271,14 +3273,13 @@ void connectlog_pgsql(char* id,char* datetime,int status)
return;
}
//使用mq
Ckafka_data_t connect_info;
connect_info.strTopic = QString::fromStdString(G_CONNECT_TOPIC);
connect_info.mp_id = QString::fromLocal8Bit(id);//这里填装置id后续作为key
connect_info.strText = QString::fromStdString(std::string(jsonString));
if(g_node_id == STAT_DATA_BASE_NODE_ID){//稳态才上传
if((g_node_id == STAT_DATA_BASE_NODE_ID && RECALL_ONLY_FLAG == 0) || (g_node_id == RECALL_HIS_DATA_BASE_NODE_ID && RECALL_ONLY_FLAG == 1)){//稳态或者补招才上传
kafka_data_list_mutex.lock(); //加锁
kafka_data_list.append(connect_info); //添加 kafka发送链表
kafka_data_list_mutex.unlock(); //解锁