Skip to content

Commit

Permalink
[ISSUE #928] Fix C++ push consumer handle error code
Browse files Browse the repository at this point in the history
  • Loading branch information
lizhimins committed Jan 23, 2025
1 parent 55e7dd2 commit cb83bf5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions cpp/examples/ExampleFifoProducer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ int main(int argc, char* argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);

auto& logger = getLogger();
logger.setConsoleLevel(Level::Debug);
logger.setLevel(Level::Debug);
logger.setConsoleLevel(Level::Info);
logger.setLevel(Level::Info);
logger.init();

// Access Key/Secret pair may be acquired from management console
Expand Down Expand Up @@ -172,7 +172,7 @@ int main(int argc, char* argv[]) {

semaphore->acquire();
producer.send(std::move(message), callback);
std::cout << "Cached No." << i << " message" << std::endl;
// std::cout << "Cached No." << i << " message" << std::endl;
}
} catch (...) {
std::cerr << "Ah...No!!!" << std::endl;
Expand Down
5 changes: 5 additions & 0 deletions cpp/source/rocketmq/AsyncReceiveMessageCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ void AsyncReceiveMessageCallback::onCompletion(const std::error_code& ec, const
return;
}

if (ec == ErrorCode::NoContent) {
checkThrottleThenReceive();
return;
}

if (ec) {
SPDLOG_WARN("Receive message from {} failed. Cause: {}. Retry after 1 second.", process_queue->simpleName(), ec.message());
receiveMessageLater(std::chrono::seconds (1));
Expand Down
4 changes: 2 additions & 2 deletions cpp/source/rocketmq/SimpleConsumerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ void SimpleConsumerImpl::start() {
}
};

// refer java sdk: set refresh interval to 30 seconds
// refer java sdk: set refresh interval to 5 seconds
// org.apache.rocketmq.client.java.impl.ClientImpl#startUp
refresh_assignment_task_ = manager()->getScheduler()->schedule(
refresh_assignment_task, "RefreshAssignmentTask",
std::chrono::minutes(5), std::chrono::seconds(5));
std::chrono::seconds(5), std::chrono::minutes(5));

client_manager_->addClientObserver(shared_from_this());
}
Expand Down

0 comments on commit cb83bf5

Please sign in to comment.