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
commit 4a9426ea6484ac1f147d0e3c1b43de60db88bcce Author: Li Zhanhui <[email protected]> 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; + } } };
