Add more para for factory (#6)
diff --git a/src/main/c/native/rocketmq.h b/src/main/c/native/rocketmq.h index e4385e4..69317b4 100644 --- a/src/main/c/native/rocketmq.h +++ b/src/main/c/native/rocketmq.h
@@ -54,6 +54,8 @@ char *language_identifier; char *instance_id; int use_domain; + char *max_msg_cache_size_in_mb; + char *suspend_time_millis; } factory_property; typedef struct callback_func_struct {
diff --git a/src/main/cpp/sdk/common/UtilAll.cpp b/src/main/cpp/sdk/common/UtilAll.cpp index e6e9639..9288f77 100644 --- a/src/main/cpp/sdk/common/UtilAll.cpp +++ b/src/main/cpp/sdk/common/UtilAll.cpp
@@ -44,12 +44,17 @@ void UtilAll::init_factory_property(const ons::ONSFactoryProperty &factoryProperty, factory_property &fp, bool is_producer) { memset(&fp, 0, sizeof(factory_property)); - if (is_producer) { + string groupID(factoryProperty.getGroupId()); + if (!groupID.empty()) { fp.group_id = const_cast<char *>(factoryProperty.getProducerId()); - } else { - fp.group_id = const_cast<char *>(factoryProperty.getConsumerId()); + if (is_producer) { + fp.group_id = const_cast<char *>(factoryProperty.getProducerId()); + } else { + fp.group_id = const_cast<char *>(factoryProperty.getConsumerId()); + + } } fp.access_key = const_cast<char *>(factoryProperty.getAccessKey()); fp.access_secret = const_cast<char *>(factoryProperty.getSecretKey()); @@ -69,6 +74,11 @@ strcpy(send_msg_timeout_millis_, send_msg_timeout_millis.c_str()); fp.send_msg_timeout_millis = send_msg_timeout_millis_; + string suspend_time_millis = to_string(factoryProperty.getSuspendTimeMillis()); + char *suspend_time_millis_ = new char[suspend_time_millis.length() + 1]; + strcpy(suspend_time_millis_, suspend_time_millis.c_str()); + fp.suspend_time_millis = suspend_time_millis_; + string consume_thread_nums = to_string(factoryProperty.getConsumeThreadNums()); char *consume_thread_nums_ = new char[consume_thread_nums.length() + 1]; strcpy(consume_thread_nums_, consume_thread_nums.c_str()); @@ -104,6 +114,11 @@ strcpy(max_msg_cache_size_, max_msg_cache_size.c_str()); fp.max_msg_cache_size = max_msg_cache_size_; + string max_msg_cache_size_in_mib = to_string(factoryProperty.getMaxMsgCacheSizeInMiB()); + char *max_msg_cache_size_in_mib_ = new char[max_msg_cache_size_in_mib.length() + 1]; + strcpy(max_msg_cache_size_in_mib_, max_msg_cache_size_in_mib.c_str()); + fp.max_msg_cache_size_in_mb = max_msg_cache_size_in_mib_; + string ons_trace_switch = "true"; if (!factoryProperty.getOnsTraceSwitch()) { ons_trace_switch = "false";
diff --git a/src/main/java/org/apache/rocketmq/graalvm/CInterface.java b/src/main/java/org/apache/rocketmq/graalvm/CInterface.java index 07b64ca..cfef42d 100644 --- a/src/main/java/org/apache/rocketmq/graalvm/CInterface.java +++ b/src/main/java/org/apache/rocketmq/graalvm/CInterface.java
@@ -69,6 +69,10 @@ static class CPropertiesDirectives implements CContext.Directives { public List<String> getOptions() { + /* + * When Gcc version is 5.X, it support Dual_ABI, if needed, Open it. + * Set it to 0 as default + */ if ("true".equalsIgnoreCase(System.getProperty("OPEN_DUAL_ABI"))) { System.out.println("-D_GLIBCXX_USE_CXX11_ABI=1 -I/usr/local/include"); return Arrays.asList("-D_GLIBCXX_USE_CXX11_ABI=1 -I/usr/local/include"); @@ -243,6 +247,19 @@ @CField("use_domain") void setUseDomain(int value); + + @CField("max_msg_cache_size_in_mb") + CCharPointer getMaxMsgCacheSizeInMb(); + + @CField("max_msg_cache_size_in_mb") + void setMaxMsgCacheSizeInMb(CCharPointer value); + + @CField("suspend_time_millis") + CCharPointer getSuspendTimeMillis(); + + @CField("suspend_time_millis") + void setSuspendTimeMillis(CCharPointer value); + } @CStruct("callback_func") interface CCallbackFunc extends PointerBase { @@ -365,6 +382,8 @@ String sendMsgTimeoutMillis = CTypeConversion.toJavaString(property.getSendMsgTimeoutMillis()); String languageIdentifier = CTypeConversion.toJavaString(property.getLanguageIdentifier()); String instanceId = CTypeConversion.toJavaString(property.getInstanceId()); + String maxMsgCacheSizeInMb = CTypeConversion.toJavaString(property.getMaxMsgCacheSizeInMb()); + String suspendTimeMillis = CTypeConversion.toJavaString(property.getSuspendTimeMillis()); if (messageModel != null && !messageModel.trim().isEmpty()) { properties.put(PropertyKeyConst.MessageModel, messageModel); @@ -375,8 +394,11 @@ if (onsChannel != null) { properties.put(PropertyKeyConst.OnsChannel, onsChannel); } - if (maxMsgCacheSize != null) { - properties.put(PropertyKeyConst.MaxCachedMessageSizeInMiB, maxMsgCacheSize); + if (maxMsgCacheSize != null && Integer.valueOf(maxMsgCacheSize) > 0) { + properties.put(PropertyKeyConst.MaxCachedMessageAmount, maxMsgCacheSize); + } + if (maxMsgCacheSizeInMb != null && Integer.valueOf(maxMsgCacheSizeInMb) > 0) { + properties.put(PropertyKeyConst.MaxCachedMessageSizeInMiB, maxMsgCacheSizeInMb); } if (onsTraceSwitch != null) { properties.put(PropertyKeyConst.MsgTraceSwitch, onsTraceSwitch); @@ -387,12 +409,15 @@ if (languageIdentifier != null) { properties.put(PropertyKeyConst.LANGUAGE_IDENTIFIER, languageIdentifier); } - if (sendMsgTimeoutMillis != null) { + if (sendMsgTimeoutMillis != null && Integer.valueOf(sendMsgTimeoutMillis) >= 0) { int sendMsgTimeoutMillis_ = Integer.parseInt(sendMsgTimeoutMillis); - if (sendMsgTimeoutMillis_ >= 100 && sendMsgTimeoutMillis_ < 3000) { + if (sendMsgTimeoutMillis_ >= 100 && sendMsgTimeoutMillis_ <= 3000) { properties.put(PropertyKeyConst.SendMsgTimeoutMillis, sendMsgTimeoutMillis); } } + if (suspendTimeMillis != null && Integer.valueOf(suspendTimeMillis) >= 0) { + properties.put(PropertyKeyConst.SuspendTimeMillis, suspendTimeMillis); + } if (instanceId != null) { properties.put(PropertyKeyConst.INSTANCE_ID, instanceId); }