Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the json format of ConsumeRunningInfo and HeartBeatData compatible with RocketMQ Java main project #403

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/protocol/ConsumerRunningInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,18 @@ string ConsumerRunningInfo::encode() {
Json::FastWriter fastwrite;
string finals = fastwrite.write(root);
string key = "\"mqTable\":";
key.append("{");
key.append("[");
for (map<MessageQueue, ProcessQueueInfo>::iterator it = mqTable.begin(); it != mqTable.end(); ++it) {
key.append("[");
key.append((it->first).toJson().toStyledString());
key.erase(key.end() - 1);
key.append(":");
key.append(",");
key.append((it->second).toJson().toStyledString());
key.append("]");
key.append(",");
}
key.erase(key.end() - 1);
key.append("}");
key.append("]");
Comment on lines 106 to +118
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The type of mqTable in Java is TreeMap<MessageQueue, ProcessQueueInfo>, but you marshall it to a list, how does it work?


// insert mqTable to final string
key.append(",");
Expand Down
48 changes: 45 additions & 3 deletions src/protocol/HeartbeatData.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,51 @@ class ConsumerData {
Json::Value toJson() const {
Json::Value outJson;
outJson["groupName"] = groupName;
outJson["consumeFromWhere"] = consumeFromWhere;
outJson["consumeType"] = consumeType;
outJson["messageModel"] = messageModel;

switch (consumeFromWhere) {
case CONSUME_FROM_FIRST_OFFSET:
outJson["consumeFromWhere"] = "CONSUME_FROM_FIRST_OFFSET";
break;
case CONSUME_FROM_TIMESTAMP:
outJson["consumeFromWhere"] = "CONSUME_FROM_TIMESTAMP";
break;
case CONSUME_FROM_LAST_OFFSET:
outJson["consumeFromWhere"] = "CONSUME_FROM_LAST_OFFSET";
break;
case CONSUME_FROM_LAST_OFFSET_AND_FROM_MIN_WHEN_BOOT_FIRST:
outJson["consumeFromWhere"] = "CONSUME_FROM_LAST_OFFSET_AND_FROM_MIN_WHEN_BOOT_FIRST";
break;
case CONSUME_FROM_MAX_OFFSET:
outJson["consumeFromWhere"] = "CONSUME_FROM_MAX_OFFSET";
break;
case CONSUME_FROM_MIN_OFFSET:
outJson["consumeFromWhere"] = "CONSUME_FROM_MIN_OFFSET";
break;
default:
break;
}

switch (consumeType) {
case CONSUME_ACTIVELY:
outJson["consumeType"] = "CONSUME_ACTIVELY";
break;
case CONSUME_PASSIVELY:
outJson["consumeType"] = "CONSUME_PASSIVELY";
break;
default:
break;
}

switch (messageModel) {
case CLUSTERING:
outJson["messageModel"] = "CLUSTERING";
break;
case BROADCASTING:
outJson["messageModel"] = "BROADCASTING";
break;
default:
break;
}

vector<SubscriptionData>::const_iterator it = subscriptionDataSet.begin();
for (; it != subscriptionDataSet.end(); it++) {
Expand Down