You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by li...@apache.org on 2022/06/30 07:51:08 UTC
[rocketmq-clients] branch cpp updated: Complete error handling for Heartbeat
This is an automated email from the ASF dual-hosted git repository.
lizhanhui pushed a commit to branch cpp
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
The following commit(s) were added to refs/heads/cpp by this push:
new 3d9ec8f Complete error handling for Heartbeat
3d9ec8f is described below
commit 3d9ec8fc41369f1d35a176f0083be79f4a35dba0
Author: Li Zhanhui <li...@gmail.com>
AuthorDate: Thu Jun 30 15:50:59 2022 +0800
Complete error handling for Heartbeat
---
cpp/src/main/cpp/client/ClientManagerImpl.cpp | 53 ++++++++++++++++++++++-----
1 file changed, 43 insertions(+), 10 deletions(-)
diff --git a/cpp/src/main/cpp/client/ClientManagerImpl.cpp b/cpp/src/main/cpp/client/ClientManagerImpl.cpp
index 05a670b..e4be88b 100644
--- a/cpp/src/main/cpp/client/ClientManagerImpl.cpp
+++ b/cpp/src/main/cpp/client/ClientManagerImpl.cpp
@@ -16,6 +16,8 @@
*/
#include "ClientManagerImpl.h"
+#include <apache/rocketmq/v2/definition.pb.h>
+
#include <atomic>
#include <cassert>
#include <chrono>
@@ -229,26 +231,57 @@ void ClientManagerImpl::heartbeat(const std::string& target_host, const Metadata
switch (status.code()) {
case rmq::Code::OK: {
cb(ec, invocation_context->response);
- } break;
+ break;
+ }
+
+ case rmq::Code::ILLEGAL_CONSUMER_GROUP: {
+ SPDLOG_ERROR("IllegalConsumerGroup: {}. Host={}", status.message(), invocation_context->remote_address);
+ ec = ErrorCode::IllegalConsumerGroup;
+ break;
+ }
+
+ case rmq::Code::TOO_MANY_REQUESTS: {
+ SPDLOG_WARN("TooManyRequest: {}. Host={}", status.message(), invocation_context->remote_address);
+ ec = ErrorCode::TooManyRequest;
+ cb(ec, invocation_context->response);
+ break;
+ }
+
case rmq::Code::UNAUTHORIZED: {
- SPDLOG_WARN("Unauthorized: {}, host={}", status.message(), invocation_context->remote_address);
+ SPDLOG_WARN("Unauthorized: {}. Host={}", status.message(), invocation_context->remote_address);
ec = ErrorCode::Unauthorized;
cb(ec, invocation_context->response);
- } break;
- case rmq::Code::FORBIDDEN: {
- SPDLOG_WARN("Forbidden: {}, host={}", status.message(), invocation_context->remote_address);
- ec = ErrorCode::Forbidden;
+ break;
+ }
+
+ case rmq::Code::UNRECOGNIZED_CLIENT_TYPE: {
+ SPDLOG_ERROR("UnsupportedClientType: {}. Host={}", status.message(), invocation_context->remote_address);
+ ec = ErrorCode::UnsupportedClientType;
cb(ec, invocation_context->response);
- } break;
+ break;
+ }
+
+ case rmq::Code::CLIENT_ID_REQUIRED: {
+ SPDLOG_ERROR("ClientIdRequired: {}. Host={}", status.message(), invocation_context->remote_address);
+ ec = ErrorCode::ClientIdRequired;
+ cb(ec, invocation_context->response);
+ break;
+ }
+
case rmq::Code::INTERNAL_SERVER_ERROR: {
SPDLOG_WARN("InternalServerError: {}, host={}", status.message(), invocation_context->remote_address);
ec = ErrorCode::InternalServerError;
cb(ec, invocation_context->response);
- } break;
+ break;
+ }
+
default: {
- SPDLOG_WARN("NotImplemented: Please upgrade SDK to latest release. Message={}, host={}", status.message(),
+ SPDLOG_WARN("NotSupported: Please upgrade SDK to latest release. Message={}, host={}", status.message(),
invocation_context->remote_address);
- } break;
+ ec = ErrorCode::NotSupported;
+ cb(ec, invocation_context->response);
+ break;
+ }
}
};