redis使用uuid作为key

This commit is contained in:
lnk
2026-07-24 10:45:02 +08:00
parent 5d82b9d4a7
commit a8d1fba23e

View File

@@ -46,6 +46,7 @@
//添加redis stream相关头文件 //添加redis stream相关头文件
#include "../redisstream/RedisStreamMQ.h" #include "../redisstream/RedisStreamMQ.h"
#include <QSettings> #include <QSettings>
#include <QUuid>
using namespace std; using namespace std;
@@ -928,6 +929,15 @@ void ShutdownAndDestroyProducer()
RocketMQ_ShutdownAndDestroyProducer(); RocketMQ_ShutdownAndDestroyProducer();
} }
static std::string generate_uuid_key()
{
QString uuid = QUuid::createUuid().toString();
uuid.remove('{');
uuid.remove('}');
return uuid.toStdString();
}
void rocketmq_producer_send(const std::string& body, void rocketmq_producer_send(const std::string& body,
const std::string& topic, const std::string& topic,
const std::string& tags, const std::string& tags,
@@ -935,11 +945,13 @@ void rocketmq_producer_send(const std::string& body,
{ {
if (G_MQ_BACKEND == MQ_BACKEND_REDIS_STREAM) if (G_MQ_BACKEND == MQ_BACKEND_REDIS_STREAM)
{ {
const std::string uuid = generate_uuid_key();
RedisStream_producer_send( RedisStream_producer_send(
body, body,
topic, topic,
tags, tags,
keys uuid
); );
return; return;
} }