添加生产和消费提示
This commit is contained in:
@@ -686,6 +686,17 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (r->type == REDIS_REPLY_STRING) {
|
if (r->type == REDIS_REPLY_STRING) {
|
||||||
|
std::string message_id = r->str
|
||||||
|
? std::string(r->str, r->len)
|
||||||
|
: std::string();
|
||||||
|
std::cout << "[REDIS_STREAM][SEND_OK]"
|
||||||
|
<< " stream=" << stream
|
||||||
|
<< " id=" << message_id
|
||||||
|
<< " key=" << key
|
||||||
|
<< " tag=" << tag
|
||||||
|
<< " enc=" << enc
|
||||||
|
<< " body_len=" << body.size()
|
||||||
|
<< std::endl;
|
||||||
freeReplyObject(r);
|
freeReplyObject(r);
|
||||||
return REDIS_XADD_OK;
|
return REDIS_XADD_OK;
|
||||||
}
|
}
|
||||||
@@ -1023,13 +1034,19 @@ private:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ack(const std::string& stream, const std::string& id)
|
bool ack(const std::string& stream, const std::string& id)
|
||||||
{
|
{
|
||||||
redisReply* r = conn_.command("XACK %b %b %b",
|
redisReply* r = conn_.command("XACK %b %b %b",
|
||||||
stream.data(), stream.size(),
|
stream.data(), stream.size(),
|
||||||
group_.data(), group_.size(),
|
group_.data(), group_.size(),
|
||||||
id.data(), id.size());
|
id.data(), id.size());
|
||||||
if (r) freeReplyObject(r);
|
if (!r) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool acked = (r->type == REDIS_REPLY_INTEGER && r->integer > 0);
|
||||||
|
freeReplyObject(r);
|
||||||
|
return acked;
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleOne(const Sub& sub, const std::string& id, redisReply* fieldsReply)
|
void handleOne(const Sub& sub, const std::string& id, redisReply* fieldsReply)
|
||||||
@@ -1054,7 +1071,16 @@ private:
|
|||||||
|
|
||||||
rocketmq::ConsumeStatus ret = cb(msg);
|
rocketmq::ConsumeStatus ret = cb(msg);
|
||||||
if (ret == rocketmq::CONSUME_SUCCESS) {
|
if (ret == rocketmq::CONSUME_SUCCESS) {
|
||||||
ack(sub.stream, id);
|
bool acked = ack(sub.stream, id);
|
||||||
|
std::cout << "[REDIS_STREAM][CONSUME_OK]"
|
||||||
|
<< " stream=" << sub.stream
|
||||||
|
<< " id=" << id
|
||||||
|
<< " topic=" << sub.topic
|
||||||
|
<< " tag=" << msg.getTags()
|
||||||
|
<< " key=" << msg.getKeys()
|
||||||
|
<< " body_len=" << msg.getBody().size()
|
||||||
|
<< " ack=" << (acked ? "OK" : "FAIL")
|
||||||
|
<< std::endl;
|
||||||
} else {
|
} else {
|
||||||
std::cout << "[REDIS_STREAM][RETRY_LATER] stream=" << sub.stream
|
std::cout << "[REDIS_STREAM][RETRY_LATER] stream=" << sub.stream
|
||||||
<< " id=" << id << std::endl;
|
<< " id=" << id << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user