This is an automated email from the ASF dual-hosted git repository.

gosonzhang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-tubemq.git


The following commit(s) were added to refs/heads/master by this push:
     new 3af7290  [TUBEMQ-419]SetMaxPartCheckPeriodMs() negative number, 
getMessage() still lock the thread (#323)
3af7290 is described below

commit 3af72901c041e6f66c0e137eeeef5503a0e46f08
Author: gosonzhang <[email protected]>
AuthorDate: Mon Nov 23 14:10:38 2020 +0800

    [TUBEMQ-419]SetMaxPartCheckPeriodMs() negative number, getMessage() still 
lock the thread (#323)
    
    Co-authored-by: gosonzhang <[email protected]>
---
 .../tubemq-client-cpp/include/tubemq/tubemq_client.h     |  7 +++++++
 .../tubemq-client-cpp/include/tubemq/tubemq_config.h     | 16 ++++++++++++++--
 2 files changed, 21 insertions(+), 2 deletions(-)

diff --git 
a/tubemq-client-twins/tubemq-client-cpp/include/tubemq/tubemq_client.h 
b/tubemq-client-twins/tubemq-client-cpp/include/tubemq/tubemq_client.h
index 43e9fc8..1c1f965 100644
--- a/tubemq-client-twins/tubemq-client-cpp/include/tubemq/tubemq_client.h
+++ b/tubemq-client-twins/tubemq-client-cpp/include/tubemq/tubemq_client.h
@@ -43,6 +43,13 @@ class TubeMQConsumer {
   bool Start(string& err_info, const ConsumerConfig& config);
   virtual void ShutDown();
   const int32_t GetClientId() const { return client_id_; }
+  // GetMessage() use note:
+  // This GetMessage have a blocking situation: when the current
+  // consumer consumption situation is not satisfied (including
+  // without partitions to consumption, or allocated partitions but
+  // the partitions do not meet the consumption situation),
+  // the call will sleep at intervals of ConsumerConfig.GetPartCheckSliceMs(),
+  // until the total time of ConsumerConfig.GetMaxPartCheckPeriodMs
   bool GetMessage(ConsumerResult& result);
   bool Confirm(const string& confirm_context, bool is_consumed, 
ConsumerResult& result);
   bool GetCurConsumedInfo(map<string, ConsumeOffsetInfo>& consume_info_map);
diff --git 
a/tubemq-client-twins/tubemq-client-cpp/include/tubemq/tubemq_config.h 
b/tubemq-client-twins/tubemq-client-cpp/include/tubemq/tubemq_config.h
index 03e5424..496e911 100644
--- a/tubemq-client-twins/tubemq-client-cpp/include/tubemq/tubemq_config.h
+++ b/tubemq-client-twins/tubemq-client-cpp/include/tubemq/tubemq_config.h
@@ -111,11 +111,23 @@ class ConsumerConfig : public BaseConfig {
   void SetConsumePosition(ConsumePosition consume_from_where);
   const ConsumePosition GetConsumePosition() const;
   const int32_t GetMsgNotFoundWaitPeriodMs() const;
+  // SetMaxPartCheckPeriodMs() use note:
+  // The value range is [negative value, 0, positive value] and the value 
directly determines
+  // the behavior of the TubeMQConsumer.GetMessage() function:
+  // 1. if it is set to a negative value, it means that the GetMessage() 
calling thread will
+  //    be blocked forever and will not return until the consumption 
conditions are met;
+  // 2. if If it is set to 0, it means that the GetMessage() calling thread 
will only block
+  //    the ConsumerConfig.GetPartCheckSliceMs() interval when the consumption 
conditions
+  //    are not met and then return; 
+  // 3. if it is set to a positive number, it will not meet the current user 
usage (including
+  //    unused partitions or allocated partitions, but these partitions do not 
meet the usage
+  //    conditions), the GetMessage() calling thread will be blocked until the 
total time of
+  //    ConsumerConfig.GetMaxPartCheckPeriodMs expires
+  void SetMaxPartCheckPeriodMs(int32_t max_part_check_period_ms);
   const int32_t GetMaxPartCheckPeriodMs() const;
+  void SetPartCheckSliceMs(uint32_t part_check_slice_ms);
   const uint32_t GetPartCheckSliceMs() const;
   void SetMsgNotFoundWaitPeriodMs(int32_t msg_notfound_wait_period_ms);
-  void SetMaxPartCheckPeriodMs(int32_t max_part_check_period_ms);
-  void SetPartCheckSliceMs(uint32_t part_check_slice_ms);
   const int32_t GetMaxSubinfoReportIntvl() const;
   void SetMaxSubinfoReportIntvl(int32_t max_subinfo_report_intvl);
   bool IsRollbackIfConfirmTimeout();

Reply via email to